Thanks for the quick reply. Here's what I have now. It's reporting the 
opposite of of the Caps Lock state. In other words, (Fl::event_state() & 
FL_CAPS_LOCK) is zero when Caps Lock is on, and nonzero when it's off.

Is that what you meant in your last message?

I'm less than enthusiastic about displaying the 'Caps Lock is on' 
message when the test in the code says it's off.

Is there really no alternative?

Thanks,
Howard Rubin

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Secret_Input.H>
#include <iostream>

class myWindow : public Fl_Window {
public:
     myWindow(int x, int y, const char* l) : Fl_Window(x, y, l) { }

     virtual int handle(int event) {
         if (event== FL_SHORTCUT && Fl::event_key() == FL_Caps_Lock) {
             static int n = 0;
             if (Fl::event_state() & FL_CAPS_LOCK) {
                 std::cout << "caps lock" << " " << ++n << std::endl;
             } else {
                 std::cout << "caps unlock" << " " << ++n << std::endl;
             }
             return 1;
         } else
             return Fl_Window::handle(event);
     }
};

int main(int argc, char* argv[]) {
     myWindow* win = new myWindow(300, 200, "");

     new Fl_Secret_Input(20, 20, 100, 15, "");

     win->end();
     win->show();

     return Fl::run();
}


_______________________________________________
fltk mailing list
fltk@easysw.com
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to