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
This commit is contained in:
Paul Licameli 2019-12-28 19:49:18 -05:00
parent fb5e871d0a
commit 8b532546c9
1 changed files with 16 additions and 9 deletions

View File

@ -11,6 +11,7 @@
#include "KeyboardCapture.h"
#if defined(__WXMAC__)
#include <wx/textctrl.h>
#include <AppKit/AppKit.h>
#include <wx/osx/private.h>
#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<wxButton*>( 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<wxTextCtrl*>(focus);
if ( !(text && text->IsMultiLine()) ) {
if (auto top =
dynamic_cast< wxTopLevelWindow* >(
wxGetTopLevelParent( focus ) ) ) {
if ( auto button =
dynamic_cast<wxButton*>( top->GetDefaultItem() ) ) {
wxCommandEvent newEvent{ wxEVT_BUTTON, button->GetId() };
button->GetEventHandler()->AddPendingEvent( newEvent );
return Event_Processed;
}
}
}
}