mirror of https://github.com/fltk/fltk
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.
This commit is contained in:
parent
1f5472a7d3
commit
f3b490134e
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue