From 9b27eaad438e9eb0ded4e73a9014308a02942a1c Mon Sep 17 00:00:00 2001 From: Dan Korn Date: Wed, 18 Aug 2021 23:07:42 +0200 Subject: [PATCH] Handle standard Cmd-{Y,Z} key combinations in Mac wxTextCtrl Use them to undo and redo, as expected. --- src/osx/textctrl_osx.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 118bf388c3..98f5950844 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -342,7 +342,7 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event) void wxTextCtrl::OnKeyDown(wxKeyEvent& event) { - if ( event.GetModifiers() == wxMOD_CONTROL ) + if ( event.ControlDown() ) { switch( event.GetKeyCode() ) { @@ -361,6 +361,18 @@ void wxTextCtrl::OnKeyDown(wxKeyEvent& event) if ( CanCut() ) Cut() ; return; + case 'Z': + if ( !event.ShiftDown() ) + { + if ( CanUndo() ) + Undo() ; + return; + } + // else fall through to Redo + case 'Y': + if ( CanRedo() ) + Redo() ; + return; default: break; }