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).
This commit is contained in:
fuscated
2019-04-27 21:21:45 +03:00
committed by Stefan Csomor
parent 491c131886
commit 3d65840f8f

View File

@@ -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 )