On 24.10.2011 09:38, Edzard Egberts wrote:
> I want to prevent Fl_Window from being closed by button escape [Esc].
>
> I found window is closing because of Fl::Fl::handle_():
>
> // make Escape key close windows:
> if (event_key()==FL_Escape) {
> wi = modal(); if (!wi) wi = window;
> wi->do_callback();
> return 1;
> }
>
> Should I rebuild FLTK without this, or is there a way to deactivate?
>
> Writing a callback like
>
> void Cb_Close(Fl_Widget* o, void* v)
> {
> if (Fl::event_key()!= FL_Escape) Test.hide();
> else Fl::event_key(0); // No effect!
>
> }
>
> leaves the problem, that window doesn't close by mouse, when Escape was
> pressed before.
I use (something like) this in my window callback:
void close_cb(Fl_Widget*o, void*) {
if ((Fl::event() == FL_KEYDOWN || Fl::event() == FL_SHORTCUT)
&& Fl::event_key() == FL_Escape)
return; // ignore ESC
else o->hide();
}
Note that you may have to cast "o" to (Fl_Window*) if you use
an older FLTK version, since hide() wasn't virtual in FLTK 1.1.x
(I don't know if we changed it in FLTK 1.1 already or only in 1.3).
Albrecht
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk