[yast-devel] YCP: how to permanently bind the Enter key to a PushButton?
Hello, I like to permanently bind the Enter key to a PushButton. Currently I have in source/printer/src/basicadd.ycp --------------------------------------------------------------- `HBox ( `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ), `InputField ( `id(`driver_filter_input), --------------------------------------------------------------- I use `opt(`default) because this button must be the default so that it is activated when the user pressed the Enter key because when the user has clicked into the InputField to enter a search string, it is normal to finish entering by pressing the Enter key but if the Enter key was linked to 'Next' or 'Back' (which is the default), the user would get the wrong action. Unfortunately `opt(`default) does not work here. I assume whatever Wizard::... function call afterwards invalids this `opt(`default) and re-sets the default back to 'Next' or 'Back'. Therefore I added in source/printer/src/basicadd.ycp --------------------------------------------------------------- any user_input = nil; while( true ) { UI::SetFocus( `apply_driver_filter ); user_input = UI::UserInput(); --------------------------------------------------------------- as an attempt to re-set the default to my button but this does not help. My button has initially the focus but after the user had clicked into the InputField to enter a search string, the focus is of course gone and the Enter key is not linked to my button. Therefore my question how to _permanently_ bind the Enter key to a PushButton? Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hi,
I like to permanently bind the Enter key to a PushButton.
Currently I have in source/printer/src/basicadd.ycp --------------------------------------------------------------- `HBox ( `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ), `InputField ( `id(`driver_filter_input), ---------------------------------------------------------------
Hmm, I did exactly the same in webpin client ... (http://bugzilla.novell.com/show_bug.cgi?id=538774)
Unfortunately `opt(`default) does not work here.
... and it worked reasonably well for me. Odd :( Which UI are you trying, btw? It doesn't (never did and never will) work in ncurses. Then maybe you're hitting a Gtk bug I had reported and Ricardo fixed in the meantime (http://bugzilla.novell.com/show_bug.cgi?id=558900)
I assume whatever Wizard::... function call afterwards invalids this `opt(`default) and re-sets the default back to 'Next' or 'Back'.
I assumed this was gonna happen too, but in the end it was not the case. Back then, to solve the problem I was thinking about adding a new function to Wizard, something like Wizard::SetNextButtonNonDefault( any id, string label ) - much alike to existing SetNextButton() call, just without `opt(`default) Which Wizard:: calls are used here? Maybe we'll need to extend the Wizard API and/or fine-tune Wizard widget (used by GUIs) now ... fB. -- \\\\\ Katarina Machalkova \\\\\\\__o YaST developer __\\\\\\\'/_ & hedgehog painter
Hello Katarina, On Jan 20 13:17 Katarina Machalkova wrote (shortened):
I like to permanently bind the Enter key to a PushButton.
Currently I have in source/printer/src/basicadd.ycp --------------------------------------------------------------- `HBox ( `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ), `InputField ( `id(`driver_filter_input), ---------------------------------------------------------------
Hmm, I did exactly the same in webpin client ... (http://bugzilla.novell.com/show_bug.cgi?id=538774)
Unfortunately `opt(`default) does not work here.
... and it worked reasonably well for me. Odd :(
I use exactly the same since a longer time in yast2-scanner in source/scanner/src/dialogs.ycp where it worked and works all the time as far as I remember for Qt and Gtk but it does not work for yast2-printer in source/printer/src/basicadd.ycp
Which UI are you trying, btw? It doesn't (never did and never will) work in ncurses. Then maybe you're hitting a Gtk bug I had reported and Ricardo fixed in the meantime (http://bugzilla.novell.com/show_bug.cgi?id=558900)
Ahh! It works for me in yast2-printer with Qt but not with Gtk so that it seems yast2-printer is hit by another instance of http://bugzilla.novell.com/show_bug.cgi?id=558900
I assume whatever Wizard::... function call afterwards invalids this `opt(`default) and re-sets the default back to 'Next' or 'Back'.
I assumed this was gonna happen too, but in the end it was not the case. Back then, to solve the problem I was thinking about adding a new function to Wizard, something like Wizard::SetNextButtonNonDefault( any id, string label ) - much alike to existing SetNextButton() call, just without `opt(`default)
For me Wizard::SetNextButtonNonDefault looks like a somehow indirect workaround for the initial issue which is to set a particular widget to be the one which the Enter key triggers so that its widget ID is the result of UI::UserInput. Therefore I would more prefer to have a direct function to bind the Enter key to a widget if this is possible. If such a function exists, it may also enable the widget if it is in state 'disabled'.
Which Wizard:: calls are used here? Maybe we'll need to extend the Wizard API and/or fine-tune Wizard widget (used by GUIs) now ...
If you still need the exact code, it is perhaps easiest to look directly at source/printer/src/basicadd.ycp in YaST SVN. Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hello, FYI: It seems I found a way how to fix user input usability: In each run of the UI::UserInput while loop directly before I call UI::UserInput() I do first replace the [Search for] button with itself with `opt(`default) to enforce this default regardless whatever function call or UI bug may have changed it and then I set the focus to the InputField for the search string so that the user can just start typing and hit Enter to get what he wants. It does not work the other way round, i.e. first set the focus then the default widget because it seems setting the default widget sets also the focus to it. See source/printer/src/basicadd.ycp in current YaST SVN: ----------------------------------------------------------------- `ReplacePoint ( `id(`apply_driver_filter_replace_point), `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ) ), ... `InputField ( `id(`driver_filter_input), . . . any user_input = nil; while( true ) { UI::ReplaceWidget( `id(`apply_driver_filter_replace_point), `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ) ); UI::SetFocus( `driver_filter_input ); user_input = UI::UserInput(); ------------------------------------------------------------------ At least currently for me on my workstation it works with Qt and Gtk (regardless of bnc#558900) as a normal user would presumably expect. For ncurses UI::SetFocus works well (see next paragraph) but `opt(`default) seems to work not at all in ncurses as already explained in Katarina's mail before. The only minor issue from my usability point of view in Qt and Gtk is that UI::SetFocus for an InputField preselects the whole input content so that a single backspace key hit removes the whole input content instead of only the last character according to what backspace normally does (at least in traditional programs which I normally use) and how it works for ncurses. But I see this behaviour so often in whatever GUIs that it seems it was carefully designed to work nowadays intentionally this way ;-) Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
Hello, FYI: On Jan 20 16:47 Johannes Meixner wrote (shortened):
It seems I found a way how to fix user input usability:
In each run of the UI::UserInput while loop directly before I call UI::UserInput() I do first replace the [Search for] button with itself with `opt(`default) to enforce this default regardless whatever function call or UI bug may have changed it and then I set the focus to the InputField for the search string so that the user can just start typing and hit Enter to get what he wants.
It is annoying in particular in the text-only ncurses UI when the focus becomes unconditioned set to the search string in each run of the UI::UserInput while loop. Therefore I changed it as follows: Only when the user did already a search directly before, set the focus to the InputField for the search string so that the user can just type in another search string. Now there is in source/printer/src/basicadd.ycp in current YaST SVN: ----------------------------------------------------------------- `ReplacePoint ( `id(`apply_driver_filter_replace_point), `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ) ), ... `InputField ( `id(`driver_filter_input), . . . any user_input = nil; while( true ) { UI::ReplaceWidget( `id(`apply_driver_filter_replace_point), `PushButton ( `id(`apply_driver_filter), `opt(`default), _("&Search for") ) ); if( `apply_driver_filter == user_input ) { UI::SetFocus( `driver_filter_input ); } user_input = UI::UserInput(); ------------------------------------------------------------------ It seems it becomes more and more complicated to implement a usable search functionality which indicates that in the end I may have to remove all those sophisticated code because it may result more and more weird side effects so that in the end the only possible way out is to fall back and use whatever GUI default behaviour as is. Kind Regards Johannes Meixner -- SUSE LINUX Products GmbH, Maxfeldstrasse 5, 90409 Nuernberg, Germany AG Nuernberg, HRB 16746, GF: Markus Rex -- To unsubscribe, e-mail: yast-devel+unsubscribe@opensuse.org For additional commands, e-mail: yast-devel+help@opensuse.org
participants (2)
-
Johannes Meixner
-
Katarina Machalkova