X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7475e8a313860781303b11e3a13e25e1a0914861..42ba812b705cec0ebef0fb65bb72d27a1378b316:/src/generic/treectlg.cpp diff --git a/src/generic/treectlg.cpp b/src/generic/treectlg.cpp index 2fbe7cde63..3fb31eb750 100644 --- a/src/generic/treectlg.cpp +++ b/src/generic/treectlg.cpp @@ -449,6 +449,7 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event ) case WXK_ESCAPE: Finish(); + m_owner->OnRenameCancelled(m_itemEdited); break; default: @@ -1512,13 +1513,13 @@ void wxGenericTreeCtrl::ExpandAll(const wxTreeItemId& item) if ( !IsExpanded(item) ) return; } - + long cookie; wxTreeItemId child = GetFirstChild(item, cookie); while ( child.IsOk() ) { ExpandAll(child); - + child = GetNextChild(item, cookie); } } @@ -2515,12 +2516,20 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) case ' ': case WXK_RETURN: + if ( !event.HasModifiers() ) { wxTreeEvent event( wxEVT_COMMAND_TREE_ITEM_ACTIVATED, GetId() ); event.m_item = (long) m_current; event.SetEventObject( this ); GetEventHandler()->ProcessEvent( event ); } + + // in any case, also generate the normal key event for this key, + // even if we generated the ACTIVATED event above: this is what + // wxMSW does and it makes sense because you might not want to + // process ACTIVATED event at all and handle Space and Return + // directly (and differently) which would be impossible otherwise + event.Skip(); break; // up goes to the previous sibling or to the last @@ -2664,14 +2673,14 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event ) default: // do not use wxIsalnum() here - if ( !event.HasModifiers() && + if ( !event.HasModifiers() && ((keyCode >= '0' && keyCode <= '9') || (keyCode >= 'a' && keyCode <= 'z') || (keyCode >= 'A' && keyCode <= 'Z' ))) { // find the next item starting with the given prefix char ch = (char)keyCode; - + wxTreeItemId id = FindItem(m_current, m_findPrefix + (wxChar)ch); if ( !id.IsOk() ) { @@ -2784,10 +2793,26 @@ bool wxGenericTreeCtrl::OnRenameAccept(wxGenericTreeItem *item, le.m_item = (long) item; le.SetEventObject( this ); le.m_label = value; + le.m_editCancelled = FALSE; return !GetEventHandler()->ProcessEvent( le ) || le.IsAllowed(); } +void wxGenericTreeCtrl::OnRenameCancelled(wxGenericTreeItem *item) +{ + // let owner know that the edit was cancelled + wxTreeEvent le( wxEVT_COMMAND_TREE_END_LABEL_EDIT, GetId() ); + le.m_item = (long) item; + le.SetEventObject( this ); + le.m_label = wxEmptyString; + le.m_editCancelled = FALSE; + + GetEventHandler()->ProcessEvent( le ); +} + + + + void wxGenericTreeCtrl::OnRenameTimer() { Edit( m_current );