]> git.saurik.com Git - wxWidgets.git/commitdiff
Changed semantics of clicking beside the text control
authorRobert Roebling <robert@roebling.de>
Sun, 9 Dec 2001 21:15:56 +0000 (21:15 +0000)
committerRobert Roebling <robert@roebling.de>
Sun, 9 Dec 2001 21:15:56 +0000 (21:15 +0000)
   when editing a label. This now accepts the input.
 My attempt to make the focus return to the owning
   tree and list control window failed.

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

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

index d3725573758f3dab06210750b771ea59f876c848..5e7ce897adeb7f15ee9e0929f6c8b48534ce777e 100644 (file)
@@ -502,6 +502,7 @@ private:
     wxString           *m_res;
     wxListMainWindow   *m_owner;
     wxString            m_startValue;
+    bool                m_finished;
 
 public:
     wxListTextCtrl() {}
@@ -2139,6 +2140,7 @@ wxListTextCtrl::wxListTextCtrl( wxWindow *parent,
     (*m_accept) = FALSE;
     (*m_res) = "";
     m_startValue = value;
+    m_finished = FALSE;
 }
 
 void wxListTextCtrl::OnChar( wxKeyEvent &event )
@@ -2151,9 +2153,12 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
         if (!wxPendingDelete.Member(this))
             wxPendingDelete.Append(this);
 
-        if ((*m_accept) && ((*m_res) != m_startValue))
+        if ((*m_res) != m_startValue)
             m_owner->OnRenameAccept();
 
+        m_finished = TRUE;
+        m_owner->SetFocus(); // This doesn't work. TODO.
+
         return;
     }
     if (event.m_keyCode == WXK_ESCAPE)
@@ -2164,6 +2169,9 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
         if (!wxPendingDelete.Member(this))
             wxPendingDelete.Append(this);
 
+        m_finished = TRUE;
+        m_owner->SetFocus(); // This doesn't work. TODO.
+
         return;
     }
 
@@ -2172,12 +2180,18 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
 
 void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
 {
+    if (m_finished)
+    {
+        event.Skip();
+        return;
+    }
+
     // auto-grow the textctrl:
     wxSize parentSize = m_owner->GetSize();
     wxPoint myPos = GetPosition();
     wxSize mySize = GetSize();
     int sx, sy;
-    GetTextExtent(GetValue() + _T("MM"), &sx, &sy); // FIXME: MM??
+    GetTextExtent(GetValue() + _T("M"), &sx, &sy); // FIXME: MM??
     if (myPos.x + sx > parentSize.x)
         sx = parentSize.x - myPos.x;
     if (mySize.x > sx)
@@ -2187,12 +2201,21 @@ void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
     event.Skip();
 }
 
-void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
+void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
 {
+    if (m_finished)
+    {
+        event.Skip();
+        return;
+    }
+
     if (!wxPendingDelete.Member(this))
         wxPendingDelete.Append(this);
 
-    if ((*m_accept) && ((*m_res) != m_startValue))
+    (*m_accept) = TRUE;
+    (*m_res) = GetValue();
+    
+    if ((*m_res) != m_startValue)
         m_owner->OnRenameAccept();
 }
 
index f33efdf928da0fd9a2c054b386a9e1bca7f1683d..71f27e271d417eeca16cff1d37e12100aabfbe78 100644 (file)
@@ -96,6 +96,7 @@ private:
     wxString           *m_res;
     wxGenericTreeCtrl  *m_owner;
     wxString            m_startValue;
+    bool                m_finished;
 
     DECLARE_EVENT_TABLE()
 };
@@ -304,21 +305,24 @@ wxTreeTextCtrl::wxTreeTextCtrl( wxWindow *parent,
     (*m_accept) = FALSE;
     (*m_res) = wxEmptyString;
     m_startValue = value;
+    m_finished = FALSE;
 }
 
 void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
 {
-    // TODO focus doesn't return to the wxTextCtrl when this closes...
     if (event.m_keyCode == WXK_RETURN)
     {
         (*m_accept) = TRUE;
         (*m_res) = GetValue();
 
-        if ((*m_accept) && ((*m_res) != m_startValue))
+        if ((*m_res) != m_startValue)
             m_owner->OnRenameAccept();
 
         if (!wxPendingDelete.Member(this))
             wxPendingDelete.Append(this);
+            
+        m_finished = TRUE;
+        m_owner->SetFocus(); // This doesn't work. TODO.
 
         return;
     }
@@ -330,6 +334,9 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
         if (!wxPendingDelete.Member(this))
             wxPendingDelete.Append(this);
 
+        m_finished = TRUE;
+        m_owner->SetFocus(); // This doesn't work. TODO.
+
         return;
     }
     event.Skip();
@@ -337,12 +344,18 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
 
 void wxTreeTextCtrl::OnKeyUp( wxKeyEvent &event )
 {
+    if (m_finished)
+    {
+        event.Skip();
+        return;
+    }
+
     // auto-grow the textctrl:
     wxSize parentSize = m_owner->GetSize();
     wxPoint myPos = GetPosition();
     wxSize mySize = GetSize();
     int sx, sy;
-    GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
+    GetTextExtent(GetValue() + _T("M"), &sx, &sy);
     if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
     if (mySize.x > sx) sx = mySize.x;
     SetSize(sx, -1);
@@ -350,12 +363,21 @@ void wxTreeTextCtrl::OnKeyUp( wxKeyEvent &event )
     event.Skip();
 }
 
-void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
+void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
 {
+    if (m_finished)
+    {
+        event.Skip();
+        return;
+    }
+
     if (!wxPendingDelete.Member(this))
         wxPendingDelete.Append(this);
 
-    if ((*m_accept) && ((*m_res) != m_startValue))
+    (*m_accept) = TRUE;
+    (*m_res) = GetValue();
+    
+    if ((*m_res) != m_startValue)
         m_owner->OnRenameAccept();
 }