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();
}