From 8b532546c905af1168a5d654dc71dda6a5188af5 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Sat, 28 Dec 2019 19:49:18 -0500 Subject: [PATCH] Bug2267: Nyquist prompt should allow multiline input... ... Fixing a side effect of the fix for bugs 2107 and 1329 which was done at commit da66806 in version 2.3.3 --- src/KeyboardCapture.cpp | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/KeyboardCapture.cpp b/src/KeyboardCapture.cpp index a6f2e412e..030025a3e 100644 --- a/src/KeyboardCapture.cpp +++ b/src/KeyboardCapture.cpp @@ -11,6 +11,7 @@ #include "KeyboardCapture.h" #if defined(__WXMAC__) +#include #include #include #elif defined(__WXGTK__) @@ -193,20 +194,26 @@ public: return Event_Skip; #ifdef __WXMAC__ - // Bug 2107 (Mac only) + // Bugs 1329 and 2107 (Mac only) // wxButton::SetDefault() alone doesn't cause correct event routing // of key-down to the button when a text entry or combo has focus, // but we can intercept wxEVT_CHAR_HOOK here and do it if ( type == wxEVT_CHAR_HOOK && key.GetKeyCode() == WXK_RETURN ) { - if (auto top = - dynamic_cast< wxTopLevelWindow* >( - wxGetTopLevelParent( wxWindow::FindFocus() ) ) ) { - if ( auto button = - dynamic_cast( top->GetDefaultItem() ) ) { - wxCommandEvent newEvent{ wxEVT_BUTTON, button->GetId() }; - button->GetEventHandler()->AddPendingEvent( newEvent ); - return Event_Processed; + const auto focus = wxWindow::FindFocus(); + // Bug 2267 (Mac only): don't apply fix for 2107 when a text entry + // needs to allow multiple line input + const auto text = dynamic_cast(focus); + if ( !(text && text->IsMultiLine()) ) { + if (auto top = + dynamic_cast< wxTopLevelWindow* >( + wxGetTopLevelParent( focus ) ) ) { + if ( auto button = + dynamic_cast( top->GetDefaultItem() ) ) { + wxCommandEvent newEvent{ wxEVT_BUTTON, button->GetId() }; + button->GetEventHandler()->AddPendingEvent( newEvent ); + return Event_Processed; + } } } }