X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/33b3ade5031832ed833c4e118ca4de724bbe7465..7735b2ea691f41d7a7f007befbe969386873b86e:/src/osx/textctrl_osx.cpp diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index cc5ac72d18..86de81f539 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -80,7 +80,7 @@ void wxTextCtrl::Init() m_maxLength = 0; m_privateContextMenu = NULL; - m_triggerOnSetValue = true ; + m_triggerUpdateEvents = true ; } wxTextCtrl::~wxTextCtrl() @@ -167,20 +167,6 @@ void wxTextCtrl::GetSelection(long* from, long* to) const GetTextPeer()->GetSelection( from , to ) ; } -void wxTextCtrl::DoSetValue(const wxString& str, int flags) -{ - // optimize redraws - if ( GetValue() == str ) - return; - - GetTextPeer()->SetStringValue( str ) ; - - if ( (flags & SetValue_SendEvent) && m_triggerOnSetValue ) - { - SendTextUpdatedEvent(); - } -} - void wxTextCtrl::SetMaxLength(unsigned long len) { m_maxLength = len ; @@ -225,10 +211,8 @@ void wxTextCtrl::Cut() { GetTextPeer()->Cut() ; - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId ); - event.SetEventObject( this ); - HandleWindowEvent( event ); - } + SendTextUpdatedEvent(); + } } void wxTextCtrl::Paste() @@ -238,10 +222,7 @@ void wxTextCtrl::Paste() GetTextPeer()->Paste() ; // TODO: eventually we should add setting the default style again - - wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, m_windowId ); - event.SetEventObject( this ); - HandleWindowEvent( event ); + SendTextUpdatedEvent(); } } @@ -307,14 +288,11 @@ wxTextPos wxTextCtrl::GetLastPosition() const return GetTextPeer()->GetLastPosition() ; } -void wxTextCtrl::Replace(long from, long to, const wxString& str) -{ - GetTextPeer()->Replace( from , to , str ) ; -} - void wxTextCtrl::Remove(long from, long to) { GetTextPeer()->Remove( from , to ) ; + if ( m_triggerUpdateEvents ) + SendTextUpdatedEvent(); } void wxTextCtrl::SetSelection(long from, long to) @@ -325,17 +303,14 @@ void wxTextCtrl::SetSelection(long from, long to) void wxTextCtrl::WriteText(const wxString& str) { GetTextPeer()->WriteText( str ) ; -} - -void wxTextCtrl::AppendText(const wxString& text) -{ - SetInsertionPointEnd(); - WriteText( text ); + if ( m_triggerUpdateEvents ) + SendTextUpdatedEvent(); } void wxTextCtrl::Clear() { GetTextPeer()->Clear() ; + SendTextUpdatedEvent(); } bool wxTextCtrl::IsModified() const @@ -605,6 +580,8 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) event.Skip(true) ; } + // osx_cocoa sends its event upon insertText +#if wxOSX_USE_CARBON if ( ( key >= 0x20 && key < WXK_START ) || ( key >= WXK_NUMPAD0 && key <= WXK_DIVIDE ) || key == WXK_RETURN || @@ -615,6 +592,7 @@ void wxTextCtrl::OnChar(wxKeyEvent& event) event1.SetEventObject( this ); wxPostEvent( GetEventHandler(), event1 ); } +#endif } // ----------------------------------------------------------------------------