Moved this question from STR#2482; Ingvar writes:
> [while using FLTK+glut]
> I tried to make my own key-up callback function, and calling it from the 
> handle:
> int UI::handle() {
>   switch (Fl::event()) {
>   case FL_KEYUP:
>     //printf("You released: %c\n", Fl::event_key());
>     callMyKeyboardUpFunc(Fl::event_key(), 0, 0); //TODO: FIX, TEST!!
>     break;
> 
> But for some reason, the handle function is not receiving any events since I 
> added my glut code.

     You should maybe show us a bit more, but note the
     handle() function's signature takes an int parameter as well.

     So you must change:

BEFORE: int UI::handle() {
  AFTER: int UI::handle(int e) {

     ..to receive events properly.

     Also, then you can use 'e' instead of Fl::event()
     in your switch().

     Be sure to also pass the event down to the base class widget
     (whatever FLTK widget your "UI" class derives from) to prevent
     eclipsing events from the widget.

     Also, be sure to preserve the return value of the base class's
     handle() call, and pass it through your call. eg:


int UI::handle(int e) {
     int ret = Fl_SomeBaseClass::handle(e);
     switch (e) {
          ..do stuff, setting 'ret=1;' if you handled and event..
     }
     return(ret);
}

      ..where Fl_SomeBaseClass is the name of the FLTK class your UI
      widget derives from.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to