Avoid duplicate wxEVT_SEARCHCTRL_CANCEL_BTN event under macOS
see https://github.com/wxWidgets/wxWidgets/pull/698 , along the idea by commit 1776f136f7d673c8e772c9ca6e1607089a071651, implemented a little bit more defensively
This commit is contained in:
@@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
@interface wxNSSearchField : NSSearchField
|
@interface wxNSSearchField : NSSearchField
|
||||||
{
|
{
|
||||||
|
BOOL m_withinTextDidChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -48,10 +49,20 @@
|
|||||||
|
|
||||||
- (id)initWithFrame:(NSRect)frame
|
- (id)initWithFrame:(NSRect)frame
|
||||||
{
|
{
|
||||||
self = [super initWithFrame:frame];
|
if ( self = [super initWithFrame:frame] )
|
||||||
|
{
|
||||||
|
m_withinTextDidChange = NO;
|
||||||
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)textDidChange:(NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
m_withinTextDidChange = YES;
|
||||||
|
[super textDidChange:aNotification];
|
||||||
|
m_withinTextDidChange = NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)controlTextDidChange:(NSNotification *)aNotification
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
wxUnusedVar(aNotification);
|
wxUnusedVar(aNotification);
|
||||||
@@ -84,6 +95,11 @@
|
|||||||
return matches;
|
return matches;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (BOOL) isWithinTextDidChange
|
||||||
|
{
|
||||||
|
return m_withinTextDidChange;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
@@ -157,7 +173,8 @@ public :
|
|||||||
NSString *searchString = [m_searchField stringValue];
|
NSString *searchString = [m_searchField stringValue];
|
||||||
if ( searchString == nil || !searchString.length )
|
if ( searchString == nil || !searchString.length )
|
||||||
{
|
{
|
||||||
wxpeer->HandleSearchFieldCancelHit();
|
if ( ![m_searchField isWithinTextDidChange])
|
||||||
|
wxpeer->HandleSearchFieldCancelHit();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user