Kveto Ilencik wrote:
> I do not want to allow the user to close their application with Alt+F4
> key combination.
Trapping ALT-F4 is similar to preventing closing the window via the
'X' button at the top right of windows.
I believe the window manager's mechanism is the same for both;
you'd do this by setting a callback for the Fl_Window, eg:
#include <stdio.h>
#include <FL/Fl.H>
#include <FL/fl_ask.H>
#include <FL/Fl_Window.H>
void MyCallback(Fl_Widget*w, void*) {
Fl_Window *win = (Fl_Window*)w;
switch ( fl_choice("Really close?", "No", "Yes", NULL) ) {
case 1: // yes
win->hide(); // closes window (or you could do an exit(0)
here too)
return;
case 0: // no
return; // ignore
}
return;
}
int main() {
Fl_Window win(300, 300, "win1");
win.end();
win.callback(MyCallback); // set callback
win.show();
return(Fl::run());
}
I'm on a linux machine, where ALT-F4 closes the window, and this
works fine. Didn't try it on windows, but I believe it should work
the same there as well.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk