summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-08-29 22:50:07 +0200
committerMatthias Melcher <github@matthiasm.com>2023-08-29 22:50:12 +0200
commitb5a1da961200e870a28f09b2fba4197e73c9935d (patch)
treec18917f0dea7f8203d020d60a2ff1d6c2cd12ff6
parentbe657471e761462d91c62e8cd00519e5dbda82a0 (diff)
FLUID: minor fixes
-rw-r--r--FL/Enumerations.H4
-rw-r--r--FL/names.h5
-rw-r--r--fluid/Fl_Widget_Type.cxx5
-rw-r--r--fluid/undo.cxx5
-rw-r--r--src/Fl_Input.cxx2
5 files changed, 15 insertions, 6 deletions
diff --git a/FL/Enumerations.H b/FL/Enumerations.H
index 178c561c3..5b7cb493a 100644
--- a/FL/Enumerations.H
+++ b/FL/Enumerations.H
@@ -455,7 +455,9 @@ enum Fl_Callback_Reason {
FL_REASON_CHANGED, ///< the value of the widget was modified
FL_REASON_GOT_FOCUS, ///< a widget received focus
FL_REASON_LOST_FOCUS, ///< a widget lost focus
- FL_REASON_RELEASED ///< the mouse button was released
+ FL_REASON_RELEASED, ///< the mouse button was released
+ FL_REASON_ENTER_KEY, ///< user finished input pressing Enter
+ FL_REASON_USER = 32 ///< user defined callback reasons
};
/**@}*/ // group: Callback Reasons
diff --git a/FL/names.h b/FL/names.h
index 87bb5178e..15a491f84 100644
--- a/FL/names.h
+++ b/FL/names.h
@@ -134,6 +134,11 @@ const char * const fl_callback_reason_names[] =
"FL_REASON_GOT_FOCUS",
"FL_REASON_LOST_FOCUS",
"FL_REASON_RELEASED",
+ "FL_REASON_ENTER_KEY",
+ NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ "FL_REASON_USER", "FL_REASON_USER+1", "FL_REASON_USER+2", "FL_REASON_USER+3",
};
/** @} */
diff --git a/fluid/Fl_Widget_Type.cxx b/fluid/Fl_Widget_Type.cxx
index 28c24939d..7418e65e1 100644
--- a/fluid/Fl_Widget_Type.cxx
+++ b/fluid/Fl_Widget_Type.cxx
@@ -405,7 +405,8 @@ void label_cb(Fl_Input* i, void *v) {
undo_resume();
if (mod) set_modflag(1);
}
- if ( (Fl::event() == FL_HIDE) || (Fl::event() == FL_UNFOCUS) )
+ int r = (int)Fl::callback_reason();
+ if ( (r == FL_REASON_LOST_FOCUS) || (r == FL_REASON_ENTER_KEY) )
first_change = 1;
}
}
@@ -2502,7 +2503,7 @@ void propagate_load(Fl_Group* g, void* v) {
Fl_Widget*const* a = g->array();
for (int i=g->children(); i--;) {
Fl_Widget* o = *a++;
- o->do_callback(o,LOAD);
+ o->do_callback(o, LOAD, FL_REASON_USER);
}
}
}
diff --git a/fluid/undo.cxx b/fluid/undo.cxx
index 21503b122..92f84a666 100644
--- a/fluid/undo.cxx
+++ b/fluid/undo.cxx
@@ -160,14 +160,15 @@ void undo_cb(Fl_Widget *, void *) {
// Save current file to undo buffer
void undo_checkpoint() {
- int undo_item = main_menubar->find_index(undo_cb);
- int redo_item = main_menubar->find_index(redo_cb);
// printf("undo_checkpoint(): undo_current=%d, undo_paused=%d, modflag=%d\n",
// undo_current, undo_paused, modflag);
// Don't checkpoint if undo_suspend() has been called...
if (undo_paused) return;
+ int undo_item = main_menubar->find_index(undo_cb);
+ int redo_item = main_menubar->find_index(redo_cb);
+
// Save the current UI to a checkpoint file...
const char *filename = undo_filename(undo_current);
if (!write_file(filename)) {
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index 6dd026b00..88ea49cc3 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -409,7 +409,7 @@ int Fl_Input::handle_key() {
case FL_KP_Enter:
if (when() & FL_WHEN_ENTER_KEY) {
insert_position(size(), 0);
- maybe_do_callback();
+ maybe_do_callback(FL_REASON_ENTER_KEY);
return 1;
} else if (multiline && !readonly()) {
return replace(insert_position(), mark(), "\n", 1);