Where is ::activate for SpinButtons?

SpinButton used to derive from Entry in GTK3, and consequently inherited the very useful activate signal and activates-default property.

Using either one of these, you could make it so that pressing enter in a spinbutton activates the default widget.

Now in GTK4 both of these are gone, because Entry was removed as a base class of SpinButton, but there doesn’t seem to be any replacement to make up for it.

The migration guide suggests things have moved to Editable, but there’s nothing in there that can be used as an activate signal or an activates-default property.

The related-looking answer SpinButton activation after user entry targets GTK3.

1 Like

In gtk4, the SpinButton uses a GtkText child for displaying the value, which offers activate signal and activates-default property.

Something weird: I don’t see convenient ways to get the GtkText, maybe gtk_widget_get_first_child(spinbutton) can do it?

The “activate” signal was not added mainly because nobody ever noticed, or thought that people would use it as a way to activate the default widget of a top level; that usually happens for actual buttons.

The SpinButton widget already listens to the “activate” signal on its child GtkText widget, and updates its value.

If you need the “activate” signal, please file an issue against GTK with a proper use case, so we can add it for the next release.

Don’t use get_first_child() or any other method for traversing the children of a widget: those are for widget implementations.

1 Like

I agree, it’s hacky. Thanks for the clarification!

What’s the next-best replacement for the activate signal right now? Doing this felt a bit hacky…

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.