X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/06f1b70464321aad204a8eb48b9f8a43a982f15d..c84ef5b9f71ea2a62daa6d70840a8d654fc0103d:/src/common/treebase.cpp diff --git a/src/common/treebase.cpp b/src/common/treebase.cpp index 57cfed1d19..4c0965c435 100644 --- a/src/common/treebase.cpp +++ b/src/common/treebase.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: treebase.cpp +// Name: src/common/treebase.cpp // Purpose: Base wxTreeCtrl classes // Author: Julian Smart // Created: 01/02/97 @@ -167,6 +167,22 @@ wxTreeEvent::wxTreeEvent(const wxTreeEvent & event) // wxTreeCtrlBase // ---------------------------------------------------------------------------- +wxTreeCtrlBase::wxTreeCtrlBase() +{ + m_imageListNormal = + m_imageListState = NULL; + m_ownsImageListNormal = + m_ownsImageListState = false; + + // arbitrary default + m_spacing = 18; + + // quick DoGetBestSize calculation + m_quickBestSize = true; + + Connect(wxEVT_CHAR_HOOK, wxKeyEventHandler(wxTreeCtrlBase::OnCharHook)); +} + wxTreeCtrlBase::~wxTreeCtrlBase() { if (m_ownsImageListNormal) @@ -335,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(GetSelection(), discardChanges); + + // Do not call Skip() below. + return; + } + } + + event.Skip(); +} + #endif // wxUSE_TREECTRL