]> git.saurik.com Git - wxWidgets.git/commitdiff
This fixes a problem in the two tree and list controls that
authorRobert Roebling <robert@roebling.de>
Mon, 7 Mar 2005 17:25:29 +0000 (17:25 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 7 Mar 2005 17:25:29 +0000 (17:25 +0000)
   are trigger if the user app shows dialog in reaction to
   the user pressing e.g. <ENTER>. The edit text control will
   lose focus and emit another event. Might be possible to
   fix without adding another field, but this way it surely
   works.
  Also added correction to treecontrol as per listcontrol in
   the situation when a label change happens by losing the
   focus and the user cannot reject it, another event is emitted.

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

src/generic/listctrl.cpp
src/generic/treectlg.cpp

index 120bdf489a9559546f2f7549904952e98caabf8d..1126d66902b435775aa6a762be072dba0b27caa9 100644 (file)
@@ -494,6 +494,7 @@ private:
     wxString            m_startValue;
     size_t              m_itemEdited;
     bool                m_finished;
+    bool                m_aboutToFinish;
 
     DECLARE_EVENT_TABLE()
 };
@@ -2032,6 +2033,7 @@ wxListTextCtrl::wxListTextCtrl(wxListMainWindow *owner, size_t itemEdit)
 {
     m_owner = owner;
     m_finished = false;
+    m_aboutToFinish = false;
 
     wxRect rectLabel = owner->GetLineLabelRect(itemEdit);
 
@@ -2082,12 +2084,11 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
     switch ( event.m_keyCode )
     {
         case WXK_RETURN:
+            m_aboutToFinish = true;
             // Notify the owner about the changes
             AcceptChanges();
-
             // Even if vetoed, close the control (consistent with MSW)
             Finish();
-
             break;
 
         case WXK_ESCAPE:
@@ -2136,7 +2137,7 @@ void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
     }
 
     // We must let the native text control handle focus, too, otherwise
-    // it could have problems with the cursor (e.g., in wxGTK):
+    // it could have problems with the cursor (e.g., in wxGTK).
     event.Skip();
 }
 
index 728cbe2f54f55ac900ac146924531c934f0b94a0..5a6c21a1b3a9b648a099544f7a7033ecd5d1eb8e 100644 (file)
@@ -108,6 +108,7 @@ private:
     wxGenericTreeItem  *m_itemEdited;
     wxString            m_startValue;
     bool                m_finished;
+    bool                m_aboutToFinish;
 
     DECLARE_EVENT_TABLE()
     DECLARE_NO_COPY_CLASS(wxTreeTextCtrl)
@@ -341,6 +342,7 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner,
 {
     m_owner = owner;
     m_finished = false;
+    m_aboutToFinish = false;
 
     int w = m_itemEdited->GetWidth(),
         h = m_itemEdited->GetHeight();
@@ -413,7 +415,7 @@ bool wxTreeTextCtrl::AcceptChanges()
 
 void wxTreeTextCtrl::Finish()
 {
-    if ( !m_finished )
+    if ( !m_finished && !m_aboutToFinish )
     {
         m_owner->ResetTextControl();
 
@@ -430,12 +432,11 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
     switch ( event.m_keyCode )
     {
         case WXK_RETURN:
+            m_aboutToFinish = true;
             // Notify the owner about the changes
             AcceptChanges();
-
             // Even if vetoed, close the control (consistent with MSW)
             Finish();
-
             break;
 
         case WXK_ESCAPE:
@@ -471,14 +472,16 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
 {
     if ( !m_finished )
     {
-        AcceptChanges();
         // We must finish regardless of success, otherwise we'll get
         // focus problems:
         Finish();
+        
+        if ( !AcceptChanges() )
+            m_owner->OnRenameCancelled( m_itemEdited );
     }
 
     // We must let the native text control handle focus, too, otherwise
-    // it could have problems with the cursor (e.g., in wxGTK):
+    // it could have problems with the cursor (e.g., in wxGTK).
     event.Skip();
 }