wxString *m_res;
wxListMainWindow *m_owner;
wxString m_startValue;
+ bool m_finished;
public:
wxListTextCtrl() {}
(*m_accept) = FALSE;
(*m_res) = "";
m_startValue = value;
+ m_finished = FALSE;
}
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)
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
+ m_finished = TRUE;
+ m_owner->SetFocus(); // This doesn't work. TODO.
+
return;
}
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)
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();
}
wxString *m_res;
wxGenericTreeCtrl *m_owner;
wxString m_startValue;
+ bool m_finished;
DECLARE_EVENT_TABLE()
};
(*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;
}
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
+ m_finished = TRUE;
+ m_owner->SetFocus(); // This doesn't work. TODO.
+
return;
}
event.Skip();
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);
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();
}