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
This commit is contained in:
Stefan Csomor
2011-02-02 07:55:57 +00:00
parent 2f250cb6e6
commit 11f87a381b
3 changed files with 22 additions and 28 deletions

View File

@@ -114,6 +114,7 @@ class wxWidgetImpl;
class wxComboBox; class wxComboBox;
class wxNotebook; class wxNotebook;
class wxTextCtrl; class wxTextCtrl;
class wxSearchCtrl;
WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl ); WXDLLIMPEXP_CORE wxWindowMac * wxFindWindowFromWXWidget(WXWidget inControl );
@@ -377,7 +378,7 @@ public :
long style, long style,
long extraStyle) ; long extraStyle) ;
static wxWidgetImplType* CreateSearchControl( wxTextCtrl* wxpeer, static wxWidgetImplType* CreateSearchControl( wxSearchCtrl* wxpeer,
wxWindowMac* parent, wxWindowMac* parent,
wxWindowID id, wxWindowID id,
const wxString& content, const wxString& content,

View File

@@ -204,7 +204,7 @@ bool wxMacSearchFieldControl::SetFocus()
return true; return true;
} }
wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer, wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxSearchCtrl* wxpeer,
wxWindowMac* WXUNUSED(parent), wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id), wxWindowID WXUNUSED(id),
const wxString& str, const wxString& str,

View File

@@ -50,33 +50,9 @@
- (id)initWithFrame:(NSRect)frame - (id)initWithFrame:(NSRect)frame
{ {
[super initWithFrame:frame]; [super initWithFrame:frame];
[self setTarget: self];
[self setAction: @selector(searchAction:)];
return self; return self;
} }
- (void) searchAction: (id) sender
{
(void) sender;
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
if ( impl )
{
wxSearchCtrl* wxpeer = dynamic_cast<wxSearchCtrl*>( impl->GetWXPeer() );
if ( wxpeer )
{
NSString *searchString = [self stringValue];
if ( searchString == nil )
{
wxpeer->HandleSearchFieldCancelHit();
}
else
{
wxpeer->HandleSearchFieldSearchHit();
}
}
}
}
- (void)controlTextDidChange:(NSNotification *)aNotification - (void)controlTextDidChange:(NSNotification *)aNotification
{ {
wxUnusedVar(aNotification); wxUnusedVar(aNotification);
@@ -150,6 +126,23 @@ public :
return wxNSTextFieldControl::SetFocus(); 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: private:
wxNSSearchField* m_searchField; wxNSSearchField* m_searchField;
NSSearchFieldCell* m_searchFieldCell; NSSearchFieldCell* m_searchFieldCell;
@@ -159,7 +152,7 @@ wxNSSearchFieldControl::~wxNSSearchFieldControl()
{ {
} }
wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxTextCtrl* wxpeer, wxWidgetImplType* wxWidgetImpl::CreateSearchControl( wxSearchCtrl* wxpeer,
wxWindowMac* WXUNUSED(parent), wxWindowMac* WXUNUSED(parent),
wxWindowID WXUNUSED(id), wxWindowID WXUNUSED(id),
const wxString& str, const wxString& str,