I have a simple Window which is modeless (make_modal(false)).
make_modal() just calls Fl_Window::set_modal and set_non_modal depending on the flag.
I think Mark's program can be translated into this in C++:
#include <FL/Enumerations.H>#include <FL/Fl.H>#include <FL/Fl_Window.H>#include <FL/Fl_Button.H>static int last_x = 0;static int last_y = 0;struct Form: public Fl_Window {Form(int x, int y, int w, int h, const char *label): Fl_Window(x, y, w, h, label) {}virtual void resize(int x, int y, int w, int h) override {
last_x = x;last_y = y;printf("last pos: %d %d\n", last_x, last_y);}void show_again() {printf("shown again at: %d %d\n", last_x, last_y);show();resize(last_x, last_y, w(), h());}};void btn_cb(Fl_Widget *w, void *data) {auto form = (Form *)data;form->show_again();}int main(int argc, char **argv) {auto win = new Fl_Window(400, 300, "Main Win");auto btn = new Fl_Button(160, 200, 80, 30, "Show");win->end();win->show();auto form = new Form(100, 100, 200, 100, "Form");form->show();btn->callback(btn_cb, form);return Fl::run();}
make_modal() just calls Fl_Window::set_modal and set_non_modal depending on the flag.
I'm used to your definition of modal (which I call application-modal). There's also system-modal (e.g., a login dialog) which normal applications should never use. And for me your normal is what I call modeless.
In this case I use a modal dialog for the application's about box (which is traditional), and a modeless dialog for the application's help window, so that the user can still interact with the main application while seeing the help text.
I wasn’t aware of the 3 states of modality, but I’ve added Window::clear_modal_states() in the latest release 1.2.21.
Here's my full list of modalities:- Modeless - a modeless window supports interaction when it has the focus but does not grab or block interaction with any other window in its own or other applications.
- Window Modal - has no effect on other windows in other applications or in this application. Used by pop up menus or other interactive popups (e.g., completion). Normally this is handled automatically by the GUI library's pop-up API.
- Modal - has no effect on other windows in other applications or in this application's windows in the same tree: here 'tree' is the top-level window and any child windows the modal dialog has been invoked on. So, for example, if you have an application and use it to open two top-level windows (e.g., two document windows), and use a modal dialog in one of those windows (e.g., a Find dialog), the modal restriction will only apply to the document window (or child) it is invoked on, and _not_ apply to the other document window (or its children).
- Application Modal - has no effect on other windows in other applications, but applies to _all_ this application's windows, even in the case of multiple top-level windows. Rarely used.
- System Modal - affects _all_ windows in _all_ applications; normally only used for the system login dialog. Dangerous to use this level of modality because a bug could make the entire system unusable.