X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4e4841b0ba8ee6e26c7b8b0643f6cfb57b0558a4..77c8efc8c37da6d6a5e2e8022d21d1cd7d76371d:/src/common/treebase.cpp diff --git a/src/common/treebase.cpp b/src/common/treebase.cpp index 06e31ddbc3..f831b489ad 100644 --- a/src/common/treebase.cpp +++ b/src/common/treebase.cpp @@ -179,6 +179,8 @@ wxTreeCtrlBase::wxTreeCtrlBase() // quick DoGetBestSize calculation m_quickBestSize = true; + + Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(wxTreeCtrlBase::OnCharHook)); } wxTreeCtrlBase::~wxTreeCtrlBase() @@ -349,4 +351,26 @@ bool wxTreeCtrlBase::IsEmpty() const return !GetRootItem().IsOk(); } +void wxTreeCtrlBase::OnCharHook(wxKeyEvent& event) +{ + if ( GetEditControl() ) + { + bool discardChanges = false; + switch ( event.GetKeyCode() ) + { + case WXK_ESCAPE: + discardChanges = true; + // fall through + + case WXK_RETURN: + EndEditLabel(GetFocusedItem(), discardChanges); + + // Do not call Skip() below. + return; + } + } + + event.Skip(); +} + #endif // wxUSE_TREECTRL