summaryrefslogtreecommitdiff
path: root/src/Fl.cxx
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-02-27 16:20:25 +0100
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2024-02-27 16:20:25 +0100
commitfc46e771cdd5b90d33fc7f895886fc43dea351c7 (patch)
tree966449959d3b12c873fd60d8b34dd640fe54b89a /src/Fl.cxx
parent746cbf861a5a441695b2fc653ed8327a9b409035 (diff)
Improve prioritization of event handlers added at open display time
Diffstat (limited to 'src/Fl.cxx')
-rw-r--r--src/Fl.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/Fl.cxx b/src/Fl.cxx
index 013d4dee1..c9a2972d2 100644
--- a/src/Fl.cxx
+++ b/src/Fl.cxx
@@ -827,6 +827,34 @@ void Fl::add_handler(Fl_Event_Handler ha) {
}
+/** Returns the last function installed by a call to Fl::add_handler() */
+Fl_Event_Handler Fl::last_handler() {
+ return handlers ? handlers->handle : NULL;
+}
+
+
+/** Install a function to parse unrecognized events with less priority than another function.
+ Install function \p ha to handle unrecognized events
+ giving it the priority just lower than that of function \p before
+ which was previously installed.
+ \see Fl::add_handler(Fl_Event_Handler)
+ \see Fl::last_handler()
+ */
+void Fl::add_handler(Fl_Event_Handler ha, Fl_Event_Handler before) {
+ if (!before) return Fl::add_handler(ha);
+ handler_link *l = handlers;
+ while (l) {
+ if (l->handle == before) {
+ handler_link *p = l->next, *q = new handler_link;
+ q->handle = ha;
+ q->next = p;
+ l->next = q;
+ return;
+ }
+ l = l->next;
+ }
+}
+
/**
Removes a previously added event handler.
\see Fl::handle(int, Fl_Window*)