How To Make Shortcut Key Always Active?

12 views
Skip to first unread message

dori...@gmail.com

unread,
Mar 21, 2015, 3:24:13 PM3/21/15
to fltkg...@googlegroups.com
Have lots of widgets in my app (designed in Fluid).  The keyboard key 'O' is defined as a shortcut on one of my buttons. That button is not always visible. Is it possible to make 'O' work (i.e. execute the callback), even when it is not displayed?  Thanks. 

Greg Ercolano

unread,
Mar 21, 2015, 4:41:01 PM3/21/15
to fltkg...@googlegroups.com
On 03/21/15 12:24, dori...@gmail.com wrote:
> Have lots of widgets in my app (designed in Fluid). The keyboard key 'O' is defined as a shortcut on one of my buttons. That button is not always visible. Is it possible to make 'O' work (i.e. execute the callback), even when it is not displayed? Thanks.

One way would be to derive a class for the window and make a handle()
method for it that looks for the FL_SHORTCUT event, and if Fl::event_key()
is the "O", trigger the button's callback via button->do_callback().

Or something like that.

FL_SHORTCUT should be received only if no other widget wants the event
(i.e. input text fields which, if they have focus, will get the keystroke instead)

Albrecht Schlosser

unread,
Mar 21, 2015, 4:53:41 PM3/21/15
to fltkg...@googlegroups.com
As Greg wrote already ... or:

Add a global shortcut handler (probably the easiest).
http://www.fltk.org/doc-1.3/group__fl__events.html#gae2d39bda7362e444afa41166c478b904

Reply all
Reply to author
Forward
0 new messages