Cancel editing in generic wxDVC when clicking outside of the editor control.

wxDataViewCtrl should behave as Explorer does on Windows: when an inline
editor control is open, clicking outside of it should close the editor
(preserving changes) in most cases - as a rule of thumb, when the
subsequent action could interfere with the editor somehow.

This was implemented by watching for focus change and so ignored clicks
made on non-focusable controls outside of wxDVC's main window area.  In
particular, clicks on the list's header were ignored, even though they
could result in modifications of the editor's position or size.

Don't finish editing when the user right-clicks on the header,
consistently with Explorer.  Opening the menu likewise still doesn't
finish editing, it is needed for access to editing operations.

Fixes #15152.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@75184 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2013-11-14 12:13:31 +00:00
parent e6b21147db
commit a4e7bf1e89

View File

@@ -257,6 +257,8 @@ protected:
}
private:
void FinishEditing();
bool SendEvent(wxEventType type, unsigned int n)
{
wxDataViewCtrl * const owner = GetOwner();
@@ -274,6 +276,8 @@ private:
void OnClick(wxHeaderCtrlEvent& event)
{
FinishEditing();
const unsigned idx = event.GetColumn();
if ( SendEvent(wxEVT_DATAVIEW_COLUMN_HEADER_CLICK, idx) )
@@ -318,6 +322,8 @@ private:
void OnResize(wxHeaderCtrlEvent& event)
{
FinishEditing();
wxDataViewCtrl * const owner = GetOwner();
const unsigned col = event.GetColumn();
@@ -327,6 +333,8 @@ private:
void OnEndReorder(wxHeaderCtrlEvent& event)
{
FinishEditing();
wxDataViewCtrl * const owner = GetOwner();
owner->ColumnMoved(owner->GetColumn(event.GetColumn()),
event.GetNewOrder());
@@ -797,6 +805,7 @@ public:
// Called by wxDataViewCtrl and our own OnRenameTimer() to start edit the
// specified item in the given column.
void StartEditing(const wxDataViewItem& item, const wxDataViewColumn* col);
void FinishEditing();
private:
int RecalculateCount() const;
@@ -2204,6 +2213,20 @@ wxDataViewMainWindow::StartEditing(const wxDataViewItem& item,
}
}
void wxDataViewMainWindow::FinishEditing()
{
if ( m_editorCtrl )
{
m_editorRenderer->FinishEditing();
}
}
void wxDataViewHeaderWindow::FinishEditing()
{
wxDataViewMainWindow *win = static_cast<wxDataViewMainWindow*>(GetOwner()->GetMainWindow());
win->FinishEditing();
}
//-----------------------------------------------------------------------------
// Helper class for do operation on the tree node
//-----------------------------------------------------------------------------