FLTK/禁用 Escape 键
外观
< FLTK
按下 Escape 键时,FLTK 应用程序会自动退出。若要禁用主窗口上的此行为,自定义回调必须替代默认回调
#include <fltk/events.h>
#include <fltk/run.h>
#include <fltk/Window.h>
#include <cstdlib>
void window_callback (fltk::Widget*) {
if (fltk::event() == fltk::KEY && fltk::event_key() == fltk::EscapeKey) {
// don't do anything when the Escape key is pressed
} else {
// exit when the user closes the window
exit(0);
}
}
int main (int argc, char** argv) {
fltk::Window window (300, 300, "FLTK test");
// set our own callback
window.callback (window_callback);
window.show (argc, argv);
return fltk::run();
}