Get wxSearchCtrl text events working, and share the text event handler code among all the various wxTextCtrl-based classes.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63415 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -173,6 +173,10 @@ public :
|
|||||||
|
|
||||||
virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
|
virtual void controlAction(WXWidget slf, void* _cmd, void* sender);
|
||||||
virtual void controlDoubleAction(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:
|
protected:
|
||||||
WXWidget m_osxView;
|
WXWidget m_osxView;
|
||||||
|
@@ -77,6 +77,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)controlTextDidChange:(NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
wxUnusedVar(aNotification);
|
||||||
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
|
if ( impl )
|
||||||
|
impl->controlTextDidChange();
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
@@ -96,15 +96,7 @@ protected :
|
|||||||
wxUnusedVar(aNotification);
|
wxUnusedVar(aNotification);
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
if ( impl )
|
if ( impl )
|
||||||
{
|
impl->controlTextDidChange();
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
|
- (void)controlTextDidEndEditing:(NSNotification *)aNotification
|
||||||
@@ -194,17 +186,10 @@ protected :
|
|||||||
|
|
||||||
- (void)textDidChange:(NSNotification *)aNotification
|
- (void)textDidChange:(NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( [aNotification object] );
|
wxUnusedVar(aNotification);
|
||||||
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
if ( impl )
|
if ( impl )
|
||||||
{
|
impl->controlTextDidChange();
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -266,15 +251,7 @@ protected :
|
|||||||
wxUnusedVar(aNotification);
|
wxUnusedVar(aNotification);
|
||||||
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
if ( impl )
|
if ( impl )
|
||||||
{
|
impl->controlTextDidChange();
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl *control, NSTextView* textView, SEL commandSelector);
|
typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl *control, NSTextView* textView, SEL commandSelector);
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#include "wx/dcclient.h"
|
#include "wx/dcclient.h"
|
||||||
#include "wx/nonownedwnd.h"
|
#include "wx/nonownedwnd.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
|
#include "wx/textctrl.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __WXMAC__
|
#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
|
#if OBJC_API_VERSION >= 2
|
||||||
|
Reference in New Issue
Block a user