wxGenericTreeItem *m_itemEdited;
wxString m_startValue;
bool m_finished;
+ bool m_aboutToFinish;
DECLARE_EVENT_TABLE()
DECLARE_NO_COPY_CLASS(wxTreeTextCtrl)
{
m_owner = owner;
m_finished = false;
+ m_aboutToFinish = false;
int w = m_itemEdited->GetWidth(),
h = m_itemEdited->GetHeight();
void wxTreeTextCtrl::Finish()
{
- if ( !m_finished )
+ if ( !m_finished )
{
m_owner->ResetTextControl();
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:
void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
{
- if ( !m_finished )
+ if ( !m_finished && !m_aboutToFinish )
{
- 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();
}
wxTreeEvent nevent( command, GetId() );
nevent.m_item = m_current;
nevent.SetEventObject(this);
+ nevent.SetPoint(pt);
// by default the dragging is not supported, the user code must
// explicitly allow the event for it to take place