summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthias Melcher <github@matthiasm.com>2023-11-05 22:10:24 +0100
committerMatthias Melcher <github@matthiasm.com>2023-11-05 22:19:03 +0100
commitf3b490134e511730d0d9f1c1ab78d57b4de11006 (patch)
tree8bdc883b81ace092b0ebc631c9255b573dd93d43 /src
parent1f5472a7d37af7909c1daa37bb5aee7296df170a (diff)
Fixes text input widget undo propagation.
If not handled, undo propagates to other random widgets, and if none takes it, it is resent as a redo to all widgets.
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Input.cxx10
-rw-r--r--src/Fl_Text_Editor.cxx8
2 files changed, 15 insertions, 3 deletions
diff --git a/src/Fl_Input.cxx b/src/Fl_Input.cxx
index 88ea49cc3..4bd799e62 100644
--- a/src/Fl_Input.cxx
+++ b/src/Fl_Input.cxx
@@ -440,8 +440,14 @@ int Fl_Input::handle_key() {
if (mods==FL_COMMAND) return kf_copy_cut(); // Ctrl-X, Mac:Meta-X (Standard/OSX-HIG)
break;
case 'z':
- if (mods==FL_COMMAND && !shift) return kf_undo(); // Ctrl-Z, Mac:Meta-Z (Standard/OSX-HIG)
- if (mods==FL_COMMAND && shift) return kf_redo(); // Shift-Ctrl-Z, Mac:Shift-Meta-Z (Standard/OSX-HIG)
+ if (mods==FL_COMMAND && !shift) { // Ctrl-Z, Mac:Meta-Z (Standard/OSX-HIG)
+ if (!kf_undo()) fl_beep();
+ return 1;
+ }
+ if (mods==FL_COMMAND && shift) { // Shift-Ctrl-Z, Mac:Shift-Meta-Z (Standard/OSX-HIG)
+ if (!kf_redo()) fl_beep();
+ return 1;
+ }
break; // handle other combos elsewhere
}
diff --git a/src/Fl_Text_Editor.cxx b/src/Fl_Text_Editor.cxx
index c548ef6be..29fb0d6e3 100644
--- a/src/Fl_Text_Editor.cxx
+++ b/src/Fl_Text_Editor.cxx
@@ -663,7 +663,13 @@ int Fl_Text_Editor::handle_key() {
Key_Func f;
f = bound_key_function(key, state, global_key_bindings);
if (!f) f = bound_key_function(key, state, key_bindings);
- if (f) return f(key, this);
+ if (f == kf_undo || f == kf_redo) {
+ // never propagate undo and redo up to another widget
+ if (!f(key, this)) fl_beep();
+ return 1;
+ } else if (f){
+ return f(key, this);
+ }
if (default_key_function_ && !state) return default_key_function_(c, this);
return 0;
}