]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix text text changed events sending in OS X combo box and text control.
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Apr 2010 18:46:29 +0000 (18:46 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 6 Apr 2010 18:46:29 +0000 (18:46 +0000)
Don't duplicate needlessly wxTextEntry functionality in wxTextCtrl.

Don't clear the combobox text entry part twice in wxComboBox::DoClear(), it is
supposed to only clear the item container contents as the base class Clear()
already calls wxTextEntry::Clear().

Do send text updated events from wxTextEntry itself as it applies to
wxComboBox just as well as to wxTextCtrl.

The unit tests now pass under wxOSX/Cocoa, not breaking them again would be
appreciated.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63881 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/osx/textctrl.h
src/osx/combobox_osx.cpp
src/osx/textctrl_osx.cpp
src/osx/textentry_osx.cpp

index 85583505fdd5dd43278181c82dcd0d9d94166aea..1116b4def81556ef8e2da849149e5ed2738c6bd4 100644 (file)
@@ -100,10 +100,6 @@ public:
     virtual void Cut();
     virtual void Paste();
     
-    virtual void WriteText(const wxString& text);
-    virtual void Clear();
-    virtual void Remove(long from, long to);
-
     // Implementation
     // --------------
     virtual void Command(wxCommandEvent& event);
@@ -148,17 +144,16 @@ protected:
     // flag is set to true when the user edits the controls contents
     bool m_dirty;
 
-    virtual void EnableTextChangedEvents(bool enable)
+    virtual void EnableTextChangedEvents(bool WXUNUSED(enable))
     {
-        m_triggerUpdateEvents = enable;
+        // nothing to do here as the events are never generated when we change
+        // the controls value programmatically anyhow
     }
 
-    bool m_triggerUpdateEvents ;
-
 private :
-  wxMenu  *m_privateContextMenu;
+    wxMenu  *m_privateContextMenu;
 
-  DECLARE_EVENT_TABLE()
+    DECLARE_EVENT_TABLE()
 };
 
 #endif // _WX_TEXTCTRL_H_
index a69e26cf8bd2cf1301bee394665b6217e43b57b4..214bdbdff4611cb5d23a4247635fc17ca8a1fd0a 100644 (file)
@@ -147,7 +147,6 @@ void wxComboBox::DoDeleteOneItem(unsigned int n)
 void wxComboBox::DoClear()
 {
     GetComboPeer()->Clear();
-    SetValue(wxEmptyString);
 }
 
 void wxComboBox::GetSelection(long *from, long *to) const
@@ -204,7 +203,8 @@ void wxComboBox::SetString(unsigned int n, const wxString& s)
 
 void wxComboBox::EnableTextChangedEvents(bool WXUNUSED(enable))
 {
-    wxFAIL_MSG("Method Not Implemented.");
+    // nothing to do here, events are never generated when we change the
+    // control value programmatically anyhow by Cocoa
 }
 
 bool wxComboBox::OSXHandleClicked( double WXUNUSED(timestampsec) )
index 4021966024a197c35e133e216e09e09b6306056f..e7e82f21c2143569cdfe143eaff4c5640f814a23 100644 (file)
@@ -79,7 +79,6 @@ void wxTextCtrl::Init()
     m_dirty = false;
 
     m_privateContextMenu = NULL;
-    m_triggerUpdateEvents = true ;
 }
 
 wxTextCtrl::~wxTextCtrl()
@@ -289,26 +288,6 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
     return GetTextPeer()->GetLineText(lineNo) ;
 }
 
-void wxTextCtrl::Remove(long from, long to)
-{
-    wxTextEntry::Remove(from, to);
-    if ( m_triggerUpdateEvents )
-        SendTextUpdatedEvent();
-}
-
-void wxTextCtrl::WriteText(const wxString& str)
-{
-    wxTextEntry::WriteText( str ) ;
-    if ( m_triggerUpdateEvents )
-        SendTextUpdatedEvent();
-}
-
-void wxTextCtrl::Clear()
-{
-    wxTextEntry::Clear() ;
-    SendTextUpdatedEvent();
-}
-
 void wxTextCtrl::Copy()
 {
     if (CanCopy())
index 3e2ca4f22dffc6933924ee23b79551a2f808c72b..2d9d79a0e2ef26743eba77ca76496f897e78eece 100644 (file)
@@ -148,6 +148,8 @@ wxTextPos wxTextEntry::GetLastPosition() const
 void wxTextEntry::Remove(long from, long to)
 {
     GetTextPeer()->Remove( from , to ) ;
+
+    SendTextUpdatedEventIfAllowed();
 }
 
 void wxTextEntry::SetSelection(long from, long to)
@@ -158,11 +160,15 @@ void wxTextEntry::SetSelection(long from, long to)
 void wxTextEntry::WriteText(const wxString& str)
 {
     GetTextPeer()->WriteText( str ) ;
+
+    SendTextUpdatedEventIfAllowed();
 }
 
 void wxTextEntry::Clear()
 {
     GetTextPeer()->Clear() ;
+
+    SendTextUpdatedEventIfAllowed();
 }
 
 bool wxTextEntry::IsEditable() const