Loic wrote:
> I now have events when I press right arrow.
> (I forgot a win->begin();)
> 
> but the event is of type
> FL_SHORTCUT = 12
> and not of type
> FL_KEYBOARD = 8
> 
> What is the trick?

        See the "Keyboard Events" section of the "Handling Events" chapter:
        http://fltk.org/doc-1.3/events.html#events_fl_keydown

        Specifically:

            "To receive FL_KEYBOARD events you must also respond to the
             FL_FOCUS and FL_UNFOCUS events.."

        ..which means returning a '1' when your widget receives
        FL_FOCUS/UNFOCUS events.

        This is all in the name of efficiency; FLTK won't waste time
        sending keyboard events to your widget if it doesn't express
        an interest in them. It only does so on the 'second pass' when
        no other widget expressed an interest in them either, so FLTK
        takes another shot at the widgets sending it as a 'shortcut',
        so that shortcuts don't eclipse eg. Fl_Input widgets.

        Or something like that, I imagine..

        I'd suggest writing your handle() method this way:

  int handle(int e) {
    int ret = Fl_Gl_Window::handle(e);
    printf("EVENT=%d\n",e);
    switch ( e ) {
      ..events you're interested in..
      case FL_FOCUS:
      case FL_UNFOCUS:
        ret = 1;                // express interest..
        break;
      case FL_KEYBOARD:
        ..handle buttons..
        ret = 1;
        break;
    }
    return(e);
  }

        HTH.
_______________________________________________
fltk-opengl mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-opengl

Reply via email to