summaryrefslogtreecommitdiff
path: root/src/Fl.cxx
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-01-05 13:51:30 +0100
committerGitHub <noreply@github.com>2023-01-05 13:51:30 +0100
commit8826dca1066361b474139bcc5aeed2e3a5246ed0 (patch)
tree6819629ff3f9f014269c7cee090ab20a824af6ad /src/Fl.cxx
parent4d1a508c7e4d28fd53129da79f068a275d7160bd (diff)
Add close buttons for individual tabs in Fl_Tabs (#628)
Add close buttons for Fl_Tabs Introducing callback reasons FLUID shows all FL_WHEN_... options Adding Fl_Tabs overflow types Improved test/tabs to show new features
Diffstat (limited to 'src/Fl.cxx')
-rw-r--r--src/Fl.cxx15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index ee16805d9..e7ba9f04d 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -69,6 +69,7 @@ const char *Fl::e_clipboard_type = "";
void *Fl::e_clipboard_data = NULL;
Fl_Event_Dispatch Fl::e_dispatch = 0;
+Fl_Callback_Reason Fl::callback_reason_ = FL_REASON_UNKNOWN;
unsigned char Fl::options_[] = { 0, 0 };
unsigned char Fl::options_read_ = 0;
@@ -1173,6 +1174,14 @@ static int send_event(int event, Fl_Widget* to, Fl_Window* window) {
return ret;
}
+/**
+ \brief Give the reason for calling a callback.
+ \return the reason for the current callback
+ \see Fl_Widget::when(), Fl_Widget::do_callback(), Fl_Widget::callback()
+ */
+Fl_Callback_Reason Fl::callback_reason() {
+ return callback_reason_;
+}
/**
\brief Set a new event dispatch function.
@@ -1258,6 +1267,8 @@ int Fl::handle(int e, Fl_Window* window)
another dispatch function. In that case, the user dispatch function must
decide when to call Fl::handle_(int, Fl_Window*)
+ Callbacks can set \p FL_REASON_CLOSED and \p FL_REASON_CANCELLED.
+
\param e the event type (Fl::event_number() is not yet set)
\param window the window that caused this event
\return 0 if the event was not handled
@@ -1275,7 +1286,7 @@ int Fl::handle_(int e, Fl_Window* window)
case FL_CLOSE:
if ( grab() || (modal() && window != modal()) ) return 0;
- wi->do_callback();
+ wi->do_callback(FL_REASON_CLOSED);
return 1;
case FL_SHOW:
@@ -1425,7 +1436,7 @@ int Fl::handle_(int e, Fl_Window* window)
// make Escape key close windows:
if (event_key()==FL_Escape) {
wi = modal(); if (!wi) wi = window;
- wi->do_callback();
+ wi->do_callback(FL_REASON_CANCELLED);
return 1;
}