From 11f87a381bd9d0fe195ff1a3802ae141413d7c2e Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 2 Feb 2011 07:55:57 +0000 Subject: [PATCH] fixing searchctrl on osx_cocoa, changing type for peer to wxSearchCtrl git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66826 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/osx/core/private.h | 3 ++- src/osx/carbon/srchctrl.cpp | 2 +- src/osx/cocoa/srchctrl.mm | 45 +++++++++++++++-------------------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 741306805a..fff53bc513 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -114,6 +114,7 @@ class wxWidgetImpl; class wxComboBox; class wxNotebook; class wxTextCtrl; +class wxSearchCtrl; WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl ); @@ -377,7 +378,7 @@ public : long style, long extraStyle) ; - static wxWidgetImplType* CreateSearchControl( wxTextCtrl* wxpeer, + static wxWidgetImplType* CreateSearchControl( wxSearchCtrl* wxpeer, wxWindowMac* parent, wxWindowID id, const wxString& content, diff --git a/src/osx/carbon/srchctrl.cpp b/src/osx/carbon/srchctrl.cpp index 5c123d6179..929340920d 100644 --- a/src/osx/carbon/srchctrl.cpp +++ b/src/osx/carbon/srchctrl.cpp @@ -204,7 +204,7 @@ bool wxMacSearchFieldControl::SetFocus() return true; } -wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer, +wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxSearchCtrl* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), const wxString& str, diff --git a/src/osx/cocoa/srchctrl.mm b/src/osx/cocoa/srchctrl.mm index d19b37c564..6e74612d73 100644 --- a/src/osx/cocoa/srchctrl.mm +++ b/src/osx/cocoa/srchctrl.mm @@ -50,33 +50,9 @@ - (id)initWithFrame:(NSRect)frame { [super initWithFrame:frame]; - [self setTarget: self]; - [self setAction: @selector(searchAction:)]; return self; } - -- (void) searchAction: (id) sender -{ - (void) sender; - wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); - if ( impl ) - { - wxSearchCtrl* wxpeer = dynamic_cast( impl->GetWXPeer() ); - if ( wxpeer ) - { - NSString *searchString = [self stringValue]; - if ( searchString == nil ) - { - wxpeer->HandleSearchFieldCancelHit(); - } - else - { - wxpeer->HandleSearchFieldSearchHit(); - } - } - } -} - + - (void)controlTextDidChange:(NSNotification *)aNotification { wxUnusedVar(aNotification); @@ -150,6 +126,23 @@ public : return wxNSTextFieldControl::SetFocus(); } + void controlAction( WXWidget WXUNUSED(slf), void *WXUNUSED(_cmd), void *WXUNUSED(sender)) + { + wxSearchCtrl* wxpeer = (wxSearchCtrl*) GetWXPeer(); + if ( wxpeer ) + { + NSString *searchString = [m_searchField stringValue]; + if ( searchString == nil ) + { + wxpeer->HandleSearchFieldCancelHit(); + } + else + { + wxpeer->HandleSearchFieldSearchHit(); + } + } + } + private: wxNSSearchField* m_searchField; NSSearchFieldCell* m_searchFieldCell; @@ -159,7 +152,7 @@ wxNSSearchFieldControl::~wxNSSearchFieldControl() { } -wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer, +wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxSearchCtrl* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), const wxString& str, -- 2.45.2