Fix missing key events for wxSearchCtrl under macOS

Use wxNSTextFieldEditor for wxSearchCtrl too, just as it was already
done for wxTextCtrl and wxComboBox, to ensure that we get these events
that seem to be consumed by the view's editor and don't reach the view
itself at all.

See #19321.

(cherry picked from commit 2bd5f383825325d5b88800b0508e5efb02fb3e91)
This commit is contained in:
Vadim Zeitlin 2022-08-04 22:01:44 +02:00
parent d013367c24
commit dc5faacf77
3 changed files with 40 additions and 8 deletions

View File

@ -449,6 +449,17 @@ public:
@end
@interface wxNSSearchField : NSSearchField
{
wxNSTextFieldEditor* fieldEditor;
BOOL m_withinTextDidChange;
}
- (wxNSTextFieldEditor*) fieldEditor;
- (void) setFieldEditor:(wxNSTextFieldEditor*) fieldEditor;
@end
@interface wxNSComboBox : NSComboBox
{
wxNSTextFieldEditor* fieldEditor;

View File

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

View File

@ -24,14 +24,6 @@
#include "wx/osx/private.h"
#include "wx/osx/cocoa/private/textimpl.h"
@interface wxNSSearchField : NSSearchField
{
BOOL m_withinTextDidChange;
}
@end
@implementation wxNSSearchField
+ (void)initialize
@ -44,6 +36,21 @@
}
}
- (void) setFieldEditor:(wxNSTextFieldEditor*) editor
{
if ( editor != fieldEditor )
{
[editor retain];
[fieldEditor release];
fieldEditor = editor;
}
}
- (wxNSTextFieldEditor*) fieldEditor
{
return fieldEditor;
}
- (id)initWithFrame:(NSRect)frame
{
if ( self = [super initWithFrame:frame] )