This fixes a problem in the two tree and list controls that
are trigger if the user app shows dialog in reaction to the user pressing e.g. <ENTER>. The edit text control will lose focus and emit another event. Might be possible to fix without adding another field, but this way it surely works. Also added correction to treecontrol as per listcontrol in the situation when a label change happens by losing the focus and the user cannot reject it, another event is emitted. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32632 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
885dd59789
commit
33fe475aeb
@ -494,6 +494,7 @@ private:
|
||||
wxString m_startValue;
|
||||
size_t m_itemEdited;
|
||||
bool m_finished;
|
||||
bool m_aboutToFinish;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
@ -2032,6 +2033,7 @@ wxListTextCtrl::wxListTextCtrl(wxListMainWindow *owner, size_t itemEdit)
|
||||
{
|
||||
m_owner = owner;
|
||||
m_finished = false;
|
||||
m_aboutToFinish = false;
|
||||
|
||||
wxRect rectLabel = owner->GetLineLabelRect(itemEdit);
|
||||
|
||||
@ -2082,12 +2084,11 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
|
||||
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:
|
||||
@ -2136,7 +2137,7 @@ void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
|
||||
}
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,7 @@ private:
|
||||
wxGenericTreeItem *m_itemEdited;
|
||||
wxString m_startValue;
|
||||
bool m_finished;
|
||||
bool m_aboutToFinish;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_NO_COPY_CLASS(wxTreeTextCtrl)
|
||||
@ -341,6 +342,7 @@ wxTreeTextCtrl::wxTreeTextCtrl(wxGenericTreeCtrl *owner,
|
||||
{
|
||||
m_owner = owner;
|
||||
m_finished = false;
|
||||
m_aboutToFinish = false;
|
||||
|
||||
int w = m_itemEdited->GetWidth(),
|
||||
h = m_itemEdited->GetHeight();
|
||||
@ -413,7 +415,7 @@ bool wxTreeTextCtrl::AcceptChanges()
|
||||
|
||||
void wxTreeTextCtrl::Finish()
|
||||
{
|
||||
if ( !m_finished )
|
||||
if ( !m_finished && !m_aboutToFinish )
|
||||
{
|
||||
m_owner->ResetTextControl();
|
||||
|
||||
@ -430,12 +432,11 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
|
||||
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:
|
||||
@ -471,14 +472,16 @@ void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
|
||||
{
|
||||
if ( !m_finished )
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user