From a2ce64695d5be49a18fdf6f688282f085fd2845b Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 22 Feb 2012 08:24:09 +0000 Subject: [PATCH] catching default button handling also in password fields git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70667 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/textctrl.mm | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 96a35ede64..d4304cb735 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -186,6 +186,39 @@ NSView* wxMacEditHelper::ms_viewCurrentlyEdited = nil; } } +- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector +{ + wxUnusedVar(textView); + + BOOL handled = NO; + + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( control ); + if ( impl ) + { + wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + if ( wxpeer ) + { + if (commandSelector == @selector(insertNewline:)) + { + wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(wxpeer), wxTopLevelWindow); + if ( tlw && tlw->GetDefaultItem() ) + { + wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton); + if ( def && def->IsEnabled() ) + { + wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() ); + event.SetEventObject(def); + def->Command(event); + handled = YES; + } + } + } + } + } + + return handled; +} + @end @interface wxNSTextScrollView : NSScrollView -- 2.45.2