提问人:Kaloschke 提问时间:11/17/2023 更新时间:11/17/2023 访问量:10
FLTK 键盘事件取决于窗口大小
FLTK Keyboard event depends on window size
问:
我想通过遥控器在 RPi 上控制 FLTK 1.3.8 应用程序,该应用程序发送键盘事件并创建了一个对遥控器代码做出反应的程序。 我的代码:
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.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");
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());
}
那行得通。 但前提是FL_Window尺寸约为 1000x1000 或更大! 例如,它不能工作 500x500。
这对我来说似乎非常难以理解。
答: 暂无答案
评论