Update all controls using in-place editors to handle Escape/Return correctly.
Define EVT_CHAR_HOOK handlers to ensure that pressing Escape/Return while an in-place edit control is active affects only it and is not used for the keyboard navigation. Closes #9102. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69897 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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(GetSelection(), discardChanges);
|
||||
|
||||
// Do not call Skip() below.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
#endif // wxUSE_TREECTRL
|
||||
|
||||
Reference in New Issue
Block a user