I want to control an FLTK 1.3.8 application on an RPi via remote control, which sends keyboard events and have created a program that reacts to the codes of the remote. My code:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/fl_ask.H>
Fl_Window *win = NULL;
const int fb_left = 65361;
class DummyBox : public Fl_Box {
public:
DummyBox(int X,int Y,int W,int H,const char *L=0) : Fl_Box(X,Y,W,H,L) { }
int handle(int e) {
int ret = Fl_Box::handle(e); // assume the buttons won't handle the keyboard events
int keyCode = Fl::event_key();
switch(e) {
case FL_FOCUS:
case FL_UNFOCUS:
ret = 1; // enables receiving keyboard events
break;
case FL_SHORTCUT: // incase widget that isn't ours has focus
case FL_KEYDOWN: // keyboard key pushed
case FL_KEYUP: // keyboard key released
{
switch(keyCode) {
case fb_left:
// system("sudo shutdown");
fl_alert ("sudo shutdown");
break;
}
break;
}
}
return(ret);
}
};
int main(int argc, char *argv[]) {
Fl_Window *win = new Fl_Window(1000,1000);
new DummyBox(0,0,0,0);
win->show();
return(Fl::run());
}
That works. BUT only, if the FL_Window size is about 1000x1000 or greater! It works not for example 500x500.
This seems very incomprehensible to me.