X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9ab7ff537d1ead0f0b07c14841474203c7fa59ba..6178debcd342963974dbdce6ac2ddb2fbe89e42a:/src/osx/cocoa/textctrl.mm diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 9dbb445eed..accef767a8 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -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(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(wxpeer)->GetValue() ); - wxpeer->HandleWindowEvent( event ); - } - } + impl->controlTextDidChange(); } @end @@ -244,7 +229,6 @@ protected : return fieldEditor; } - - (void) setEnabled:(BOOL) flag { [super setEnabled: flag]; @@ -266,15 +250,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(wxpeer)->GetValue() ); - wxpeer->HandleWindowEvent( event ); - } - } + impl->controlTextDidChange(); } typedef BOOL (*wxOSX_insertNewlineHandlerPtr)(NSView* self, SEL _cmd, NSControl *control, NSTextView* textView, SEL commandSelector); @@ -345,6 +321,14 @@ wxNSTextViewControl::~wxNSTextViewControl() [m_textView setDelegate: nil]; } +bool wxNSTextViewControl::CanFocus() const +{ + // since this doesn't work (return false), we hardcode + // if (m_textView) + // return [m_textView canBecomeKeyView]; + return true; +} + wxString wxNSTextViewControl::GetStringValue() const { if (m_textView) @@ -524,14 +508,16 @@ wxSize wxNSTextViewControl::GetBestSize() const size.y += [m_textView textContainerInset].height; return size; } + return wxSize(0,0); } // wxNSTextFieldControl -wxNSTextFieldControl::wxNSTextFieldControl( wxTextCtrl *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) +wxNSTextFieldControl::wxNSTextFieldControl( wxWindow *wxPeer, WXWidget w ) : wxWidgetCocoaImpl(wxPeer, w) { - m_textField = (NSTextField*) w; - [m_textField setDelegate: w]; + NSTextField wxOSX_10_6_AND_LATER() *tf = (NSTextField*) w; + m_textField = tf; + [m_textField setDelegate: tf]; m_selStart = m_selEnd = 0; m_hasEditor = [w isKindOfClass:[NSTextField class]]; }