GNOME Bugzilla – Bug 143832
GtkSpinButton doesn't update its value in certain cases
Last modified: 2007-01-23 16:30:59 UTC
Create a dialog with a GtkSpinButton and an "OK" button. Change the spin-button value from keyboard (i.e. by typing new value in, not by clicking on the arrows) and activate the OK button by pressing Alt+O or Enter (not by mouse or by tabbing to it and pressing space). The spin-button's adjustment's value is not updated. If you deviate from using the keyboard, it is updated. I'm not sure it is a bug, but then I don't know what to do with my program so that the new value always gets noticed. Please let me know if I should fix my program instead.
Created attachment 30493 [details] a trivial program that allows to reproduce the bug OK, I bumped into this very same bug in another program (Inkscape). This time I come with a program to reproduce it.
In these cases, the app has to call gtk_spin_button_update() - there really isn't much GTK+ can do about it automatically. See related bug 106574 (more fixable), bug 50276 (validation), bug 62948 (input methods)
Can't GTK+ send for instance a "focus-out-event" to whatever currently has focus when activating something with a keyboard? It doesn't need to actually transfer the focus, only make sure that the focused widget thinks it loses focus. Browsing through the bugs you mentioned suggest that this problem is more generic than just spin-button related. From my point of view, such behaviour is extremely non-obvious to a user and cannot be justified in usability terms.
I just wanted to ping this bug because I just ran into it myself (and wrote pretty much the same test program before looking to see if someone had filed it already) In my particular case, I can hack around this, since on my OK button press I have some known code so I can tickle the currently focused field, but if you were to do something simple-minded like use gtk_dialog_run(), that's a bit trickier. It seems really strange that by hitting control-O, I actually see the ok button depress, yet my spinbutton never sees a focus change. I guess it's a little more complicated since a callback on the spinbutton might disable the OK button/change its behavior/something. It's not completely straight-forward, but it does seem like gtk could hopefully do something.
Please, either fix it or explain why suggested method is bad or won't work.
*** This bug has been marked as a duplicate of 314926 ***