]> git.saurik.com Git - wxWidgets.git/commitdiff
Get wxSearchCtrl text events working, and share the text event handler code among...
authorKevin Ollivier <kevino@theolliviers.com>
Sat, 6 Feb 2010 17:00:38 +0000 (17:00 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Sat, 6 Feb 2010 17:00:38 +0000 (17:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63415 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/cocoa/private.h
src/osx/cocoa/srchctrl.mm
src/osx/cocoa/textctrl.mm
src/osx/cocoa/window.mm

index f7ee0900a47d1e9f7e7da46fdf8ff62b4bb36c97..62556623196821ff5a1e984913ac7f9cab34379b 100644 (file)
@@ -173,6 +173,10 @@ public :
 
     virtual void                controlAction(WXWidget slf, void* _cmd, void* sender);
     virtual void                controlDoubleAction(WXWidget slf, void* _cmd, void *sender);
+    
+    // for wxTextCtrl-derived classes, put here since they don't all derive
+    // from the same pimpl class.
+    virtual void                controlTextDidChange();
 
 protected:
     WXWidget m_osxView;
index 399729c1832fccec8b4e55530a4e015c769b39b6..e98a3cf7f3b83ae67a05225087ea5c53cf2fbd49 100644 (file)
     }
 }
 
+- (void)controlTextDidChange:(NSNotification *)aNotification
+{
+    wxUnusedVar(aNotification);
+    wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
+    if ( impl )
+        impl->controlTextDidChange();
+}
+
 @end
 
 // ============================================================================
index c288d787039cd60fdaefa76c9fee0b52eb252048..1f100891160bed4a3adf87a6f145c4332a4facf1 100644 (file)
@@ -96,15 +96,7 @@ protected :
     wxUnusedVar(aNotification);
     wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
     if ( impl )
-    {
-        wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
-        if ( wxpeer ) {
-            wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
-            event.SetEventObject( wxpeer );
-            event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
-            wxpeer->HandleWindowEvent( event );
-        }
-    }
+        impl->controlTextDidChange();
 }
 
 - (void)controlTextDidEndEditing:(NSNotification *)aNotification
@@ -194,17 +186,10 @@ protected :
 
 - (void)textDidChange:(NSNotification *)aNotification
 {
-    wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( [aNotification object] );
+    wxUnusedVar(aNotification);
+    wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
     if ( impl )
-    {
-        wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
-        if ( wxpeer ) {
-            wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
-            event.SetEventObject( wxpeer );
-            event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
-            wxpeer->HandleWindowEvent( event );
-        }
-    }
+        impl->controlTextDidChange();
 }
 
 @end
@@ -266,15 +251,7 @@ protected :
     wxUnusedVar(aNotification);
     wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
     if ( impl )
-    {
-        wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
-        if ( wxpeer ) {
-            wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
-            event.SetEventObject( wxpeer );
-            event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
-            wxpeer->HandleWindowEvent( event );
-        }
-    }
+        impl->controlTextDidChange();
 }
 
 typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl *control, NSTextView* textView, SEL commandSelector);
index 3154e3fe2c54b1fae989e475d4f2d88a9adfc34e..8ab72ea34248d46f850e13b66865573ce4a48db7 100644 (file)
@@ -15,6 +15,7 @@
     #include "wx/dcclient.h"
     #include "wx/nonownedwnd.h"
     #include "wx/log.h"
+    #include "wx/textctrl.h"
 #endif
 
 #ifdef __WXMAC__
@@ -1123,6 +1124,18 @@ void wxWidgetCocoaImpl::controlDoubleAction( WXWidget WXUNUSED(slf), void *WXUNU
 {
 }
 
+void wxWidgetCocoaImpl::controlTextDidChange()
+{
+    wxWindow* wxpeer = (wxWindow*)GetWXPeer();
+    if ( wxpeer ) 
+    {
+        wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, wxpeer->GetId());
+        event.SetEventObject( wxpeer );
+        event.SetString( static_cast<wxTextCtrl*>(wxpeer)->GetValue() );
+        wxpeer->HandleWindowEvent( event );
+    }
+}
+
 //
 
 #if OBJC_API_VERSION >= 2