Diddy wrote:
> int MyWindow::handle(int event){
> switch(event){
> case FL_KEYBOARD://keypresses
> return this->handle_key(event, Fl::event_key());
> break;
> default:
> return Fl_Widget::handle(event);
>
> However after I do this, the window no longer registers when I click
> on the Fl_Button I've also added to my window.
If you're deriving from Fl_Window,
call Fl_Window's event handler, not Fl_Widget's, eg:
BEFORE: return Fl_Widget::handle(event);
AFTER: return Fl_Window::handle(event);
^^^^^^^^^
By calling Fl_Widget instead of Fl_Window, you'll short-circuit
event delivery from the Fl_Window widget's event handler,
preventing important window-specific events from being handled
correctly.
Also, by trapping FL_KEYBOARD events as shown above, be sure
not to short circuit FL_KEYBOARD events you /don't/ handle from
Fl_Window::handle(), otherwise ALL keyboard events may not
reach child widgets. (depends on the code you have in
this->handle_key(), I can't tell).
Be careful when you define your own handle() method;
you now have control of ALL events for your widget,
and in your case it's a window, you control the
flow of events down to all the child widgets as well.
You can either inspect events and pass them through to the
base class, or inspect events and /not/ pass them down
(ie. 'handle' and discard, "eclipsing" the event from other
widgets down the hierarchy). Do the latter carefully, as some
base classes expect certain events to be in order (PUSH, RELEASE, etc)
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk