On Fri, 05 Apr 2013 23:39:28 -0700, Greg Ercolano wrote:
>       an fltk timer would probably be needed to get the correct
>       state info shown reliably.

Thanks for the replies.

No luck with an fltk timer, on Ubuntu Linux 10.04. Test program below.

In the console we can see that (Fl::event_state() & FL_CAPS_LOCK)
correctly changes to nonzero as soon as you press Caps Lock.

But it doesn't change back to 0 when you press Caps Lock again
until e.g. you move the mouse over the window.

Howard Rubin

------------------------

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

void TimerProc(void* p) {
     Fl_Output* pOutput = static_cast<Fl_Output*>(p);

     if (Fl::event_state() & FL_CAPS_LOCK) {
         pOutput->show();
         std::cerr << 1;
     } else {
         pOutput->hide();
         std::cerr << 0;
     }
     pOutput->damage(~0); pOutput->redraw(); Fl::check(); Fl::wait(.1);

     Fl::repeat_timeout(0.25, TimerProc, p);
}

int main(int argc, char* argv[]) {
     Fl_Window* win = new Fl_Window(300, 200, "");
     Fl_Output* pOutput = new Fl_Output(120, 50, 0, 15, "Caps Lock");

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

     Fl::add_timeout(0.25, TimerProc, pOutput);

     return Fl::run();
}


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

Reply via email to