> Fl::option(OPTION_ARROW_FOCUS, 0);  is incorrect syntax.

        Shouldn't be:
        http://fltk.org/doc-1.3/classFl.html#a9b040cad5d6fc04bb139877015091c16
        What svn version of 1.3.x are you using? You might have an old one.

        Regarding using spacebar as a shortcut, since spacebar (and tab and 
arrows)
        are used for keyboard nav, you first have to wholesale disable keyboard
        navigation for all widgets, otherwise they'll steal the event.

        Besides the above, there's another (older?) way to globally disable
        keyboard nav/focus box behavior: Fl::visible_focus(0|1), which in
        current commits is equivalent to the above.

        To handle the spacebar, I'd suggest instead having your window handle
        it as a regular keyboard event, eg. in the handle() method of your 
window.

        The following will probably do what you want:

#include <stdio.h>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Button.H>
class MyWindow : public Fl_Window {
public:
    MyWindow(int W, int H) : Fl_Window(W,H) {
    }
    int handle(int e) {
        int ret = Fl_Window::handle(e);
        switch (e) {
            case FL_FOCUS:
            case FL_UNFOCUS:
                ret = 1;
                break;
            case FL_KEYDOWN:
            case FL_KEYUP:
                if ( Fl::event_key() == ' ' ) { // handle space
                   if ( e == FL_KEYDOWN ) fprintf(stderr, "Spacebar hit\n");
                   ret = 1;
                }
                break;
        }
        return(ret);
    }
};
int main(int argc, char **argv) {
   Fl::visible_focus(0);                // disable visible focus globally
   MyWindow win(400,300);
   new Fl_Button(10,10,120,25,"A");
   new Fl_Button(10,40,120,25,"B");
   win.end();
   win.show();
   return(Fl::run());
}

        There's an example of general keyboard press/release handling here
        which I used for reference for the above:
        http://seriss.com/people/erco/fltk/#KeyPressRelease

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

Reply via email to