applying editor part of patch, see #15003

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73961 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Stefan Csomor
2013-05-10 18:31:51 +00:00
parent 94474c2e0b
commit d9307d006e
3 changed files with 52 additions and 6 deletions

View File

@@ -341,6 +341,18 @@ public:
@end
@interface wxNSComboBox : NSComboBox
{
wxNSTextFieldEditor* fieldEditor;
}
- (wxNSTextFieldEditor*) fieldEditor;
- (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
@end
@interface wxNSMenu : NSMenu
{
wxMenuImpl* impl;

View File

@@ -36,12 +36,6 @@
@end
@interface wxNSComboBox : NSComboBox
{
}
@end
@implementation wxNSComboBox
+ (void)initialize
@@ -54,6 +48,33 @@
}
}
- (void) dealloc
{
[fieldEditor release];
[super dealloc];
}
// Over-riding NSComboBox onKeyDown method doesn't work for key events.
// Ensure that we can use our own wxNSTextFieldEditor to catch key events.
// See windowWillReturnFieldEditor in nonownedwnd.mm.
// Key events will be caught and handled via wxNSTextFieldEditor onkey...
// methods in textctrl.mm.
- (void) setFieldEditor:(wxNSTextFieldEditor*) editor
{
if ( editor != fieldEditor )
{
[editor retain];
[fieldEditor release];
fieldEditor = editor;
}
}
- (wxNSTextFieldEditor*) fieldEditor
{
return fieldEditor;
}
- (void)controlTextDidChange:(NSNotification *)aNotification
{
wxUnusedVar(aNotification);

View File

@@ -484,6 +484,19 @@ extern int wxOSXGetIdFromSelector(SEL action );
}
return editor;
}
else if ([anObject isKindOfClass:[wxNSComboBox class]])
{
wxNSComboBox * cb = (wxNSComboBox*) anObject;
wxNSTextFieldEditor* editor = [cb fieldEditor];
if ( editor == nil )
{
editor = [[wxNSTextFieldEditor alloc] init];
[editor setFieldEditor:YES];
[cb setFieldEditor:editor];
[editor release];
}
return editor;
}
return nil;
}