On 05/07/12 20:26, leowang wrote:
> Dear All,
> I have a button, it has a callback, but I found that when the focus is on
> this button, press enter key can not auto call the callback, only use mouse
> to press button can call the callback. Why?
>
> In fltk2.0, it will auto call the callback when press enter key if the focus
> is on the button.
'Spacebar' is how you trigger things in 1.x..
buttons, menubuttons, choice menus, checkboxes, etc.
The docs for Fl_Button don't seem to mention this, but
it's been a long standing behavior in 1.x.
Fl_Group seems to use 'Enter' as a shortcut for keyboard navigation
when there's a group of buttons; it moves to the next button down.
(See Fl_Group::handle(), case FL_SHORTCUT, FL_Enter results in
navigation(FL_Down))
I would have thought setting Fl_Button::when(FL_WHEN_ENTER_KEY)
would cause it to respond to the enter key, but it does not.
Perhaps it should?
Fl_Return_Button doesn't really do what you want; it will respond
to the enter key, but there can only be one of them in a group,
and does not heed focus.
Setting Fl_Button's shortcut() to 0x0d makes it respond to the
enter key, but like Fl_Return_Button, there can only be one.
Not sure how to get what you want other than to derive a class
from Fl_Button and have it invoke the callback when FL_Enter/FL_KP_Enter
comes in as a keyboard event.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk