From 3d65840f8f2248c444875c71af144c2ff90cbe61 Mon Sep 17 00:00:00 2001 From: fuscated Date: Sat, 27 Apr 2019 21:21:45 +0300 Subject: [PATCH] Implement doCommandBySelector for the wxNSComboBox class * Use the same code as for wxNSTextField (copy-pasted). * This method is used to redirect the enter key event to the OnChar event. * This makes it possible to implement the default button activation by pressing the enter key (for comboboxes which doesn't have the wxTE_PROCESS_ENTER style). --- src/osx/cocoa/combobox.mm | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 0a4acd1190..84fd62cb2a 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -158,6 +158,44 @@ } } } + + +- (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector +{ + wxUnusedVar(textView); + wxUnusedVar(control); + + BOOL handled = NO; + + // send back key events wx' common code knows how to handle + + wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + if ( impl ) + { + wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); + if ( wxpeer ) + { + if (commandSelector == @selector(insertNewline:)) + { + [textView insertNewlineIgnoringFieldEditor:self]; + handled = YES; + } + else if ( commandSelector == @selector(insertTab:)) + { + [textView insertTabIgnoringFieldEditor:self]; + handled = YES; + } + else if ( commandSelector == @selector(insertBacktab:)) + { + [textView insertTabIgnoringFieldEditor:self]; + handled = YES; + } + } + } + + return handled; +} + @end wxNSComboBoxControl::wxNSComboBoxControl( wxComboBox *wxPeer, WXWidget w )