diff options
| author | Matthias Melcher <github@matthiasm.com> | 2023-11-22 22:31:59 +0100 |
|---|---|---|
| committer | Matthias Melcher <github@matthiasm.com> | 2023-11-22 22:31:59 +0100 |
| commit | 8041a62e594400d3cca487a4b07119a000a3020c (patch) | |
| tree | 689285b007690a84142d18601a9c3b7484a9c822 /documentation | |
| parent | f8d915cfe684b957948ce86e324a936a8cb25fb1 (diff) | |
Adds Callback Reason to FAQ on Fl_Window::callback
Diffstat (limited to 'documentation')
| -rw-r--r-- | documentation/src/faq.dox | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/documentation/src/faq.dox b/documentation/src/faq.dox index 766fe5252..e6cdf2341 100644 --- a/documentation/src/faq.dox +++ b/documentation/src/faq.dox @@ -131,6 +131,19 @@ void my_callback(Fl_Widget*, void*) { } \endcode +The reason for calling a window callback can also be found using using the +`Fl::callback_reason()` method: + +\code +void my_callback(Fl_Widget*, void*) { + if (Fl::callback_reason() == FL_REASON_CANCELLED) + return; // ignore that the user pressed the Escape key + if (Fl::callback_reason() == FL_REASON_CLOSED) + save_and_exit(); // user clicked the Close button in the window decoration + exit(0); // fallback for other callback reasons +} +\endcode + It is very common to ask for confirmation before exiting, this can be done with: |
