Update to ending a label edit action in both tree control
and list controls. This includes the patch for tree control to correct the focus behavour when cancelling a label change action. It also adds an end_label_edit event to wxListCtrl when cancelling (this was not done before). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@21698 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -652,6 +652,7 @@ public:
|
|||||||
|
|
||||||
void OnRenameTimer();
|
void OnRenameTimer();
|
||||||
bool OnRenameAccept(size_t itemEdit, const wxString& value);
|
bool OnRenameAccept(size_t itemEdit, const wxString& value);
|
||||||
|
void OnRenameCancelled(size_t itemEdit);
|
||||||
|
|
||||||
void OnMouse( wxMouseEvent &event );
|
void OnMouse( wxMouseEvent &event );
|
||||||
|
|
||||||
@@ -2302,6 +2303,7 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
|
|||||||
|
|
||||||
case WXK_ESCAPE:
|
case WXK_ESCAPE:
|
||||||
Finish();
|
Finish();
|
||||||
|
m_owner->OnRenameCancelled( m_itemEdited );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -2336,11 +2338,13 @@ void wxListTextCtrl::OnKillFocus( wxFocusEvent &event )
|
|||||||
{
|
{
|
||||||
if ( !m_finished )
|
if ( !m_finished )
|
||||||
{
|
{
|
||||||
(void)AcceptChanges();
|
// We must finish regardless of success, otherwise we'll get focus problems
|
||||||
|
|
||||||
Finish();
|
Finish();
|
||||||
|
|
||||||
|
if ( !AcceptChanges() )
|
||||||
|
m_owner->OnRenameCancelled( m_itemEdited );
|
||||||
}
|
}
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3072,6 +3076,11 @@ void wxListMainWindow::OnRenameTimer()
|
|||||||
bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value)
|
bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value)
|
||||||
{
|
{
|
||||||
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
|
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
|
||||||
|
|
||||||
|
// These only exist for wxTreeCtrl, which should probably be changed
|
||||||
|
// le.m_editCancelled = FALSE;
|
||||||
|
// le.m_label = value;
|
||||||
|
|
||||||
le.SetEventObject( GetParent() );
|
le.SetEventObject( GetParent() );
|
||||||
le.m_itemIndex = itemEdit;
|
le.m_itemIndex = itemEdit;
|
||||||
|
|
||||||
@@ -3080,10 +3089,31 @@ bool wxListMainWindow::OnRenameAccept(size_t itemEdit, const wxString& value)
|
|||||||
|
|
||||||
data->GetItem( 0, le.m_item );
|
data->GetItem( 0, le.m_item );
|
||||||
le.m_item.m_text = value;
|
le.m_item.m_text = value;
|
||||||
|
|
||||||
return !GetParent()->GetEventHandler()->ProcessEvent( le ) ||
|
return !GetParent()->GetEventHandler()->ProcessEvent( le ) ||
|
||||||
le.IsAllowed();
|
le.IsAllowed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListMainWindow::OnRenameCancelled(size_t itemEdit)
|
||||||
|
{
|
||||||
|
// let owner know that the edit was cancelled
|
||||||
|
wxListEvent le( wxEVT_COMMAND_LIST_END_LABEL_EDIT, GetParent()->GetId() );
|
||||||
|
|
||||||
|
// These only exist for wxTreeCtrl, which should probably be changed
|
||||||
|
// le.m_editCancelled = TRUE;
|
||||||
|
// le.m_label = wxEmptyString;
|
||||||
|
|
||||||
|
le.SetEventObject( GetParent() );
|
||||||
|
le.m_itemIndex = itemEdit;
|
||||||
|
|
||||||
|
wxListLineData *data = GetLine(itemEdit);
|
||||||
|
wxCHECK_RET( data, _T("invalid index in OnRenameCancelled()") );
|
||||||
|
|
||||||
|
data->GetItem( 0, le.m_item );
|
||||||
|
|
||||||
|
GetEventHandler()->ProcessEvent( le );
|
||||||
|
}
|
||||||
|
|
||||||
void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
void wxListMainWindow::OnMouse( wxMouseEvent &event )
|
||||||
{
|
{
|
||||||
event.SetEventObject( GetParent() );
|
event.SetEventObject( GetParent() );
|
||||||
|
@@ -485,16 +485,16 @@ void wxTreeTextCtrl::OnKeyUp( wxKeyEvent &event )
|
|||||||
|
|
||||||
void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
|
void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &event )
|
||||||
{
|
{
|
||||||
if ( m_finished )
|
if ( !m_finished )
|
||||||
{
|
|
||||||
event.Skip();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( AcceptChanges() )
|
|
||||||
{
|
{
|
||||||
|
// We must finish regardless of success, otherwise we'll get focus problems
|
||||||
Finish();
|
Finish();
|
||||||
|
|
||||||
|
if ( !AcceptChanges() )
|
||||||
|
m_owner->OnRenameCancelled( m_itemEdited );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
@@ -2900,14 +2900,11 @@ void wxGenericTreeCtrl::OnRenameCancelled(wxGenericTreeItem *item)
|
|||||||
le.m_item = (long) item;
|
le.m_item = (long) item;
|
||||||
le.SetEventObject( this );
|
le.SetEventObject( this );
|
||||||
le.m_label = wxEmptyString;
|
le.m_label = wxEmptyString;
|
||||||
le.m_editCancelled = FALSE;
|
le.m_editCancelled = TRUE;
|
||||||
|
|
||||||
GetEventHandler()->ProcessEvent( le );
|
GetEventHandler()->ProcessEvent( le );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void wxGenericTreeCtrl::OnRenameTimer()
|
void wxGenericTreeCtrl::OnRenameTimer()
|
||||||
{
|
{
|
||||||
Edit( m_current );
|
Edit( m_current );
|
||||||
|
Reference in New Issue
Block a user