Fix spurious label editing in generic wx{List,Tree,DataView}Ctrl.

Clicking on the control to give it focus must not start editing the label of
an item in it, this is bad UI as you need to carefully select where do you
click to avoid starting to edit the label and nobody else does it like this
(probably because of the former reason).

As a side note, it would be really great to abstract the item handling in a
class that could be reused by all these controls instead of having to update 3
slightly different versions of the same code every time.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72634 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-10-07 22:40:29 +00:00
parent e55e1a5fda
commit 15ec266ae3
3 changed files with 28 additions and 5 deletions

View File

@@ -2470,9 +2470,10 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
m_renameTimer->Start(dclick > 0 ? dclick : 250, true);
}
}
m_lastOnSame = false;
}
m_lastOnSame = false;
m_lineSelectSingleOnUp = (size_t)-1;
}
else
@@ -2564,8 +2565,16 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
if (m_current != oldCurrent)
RefreshLine( oldCurrent );
// forceClick is only set if the previous click was on another item
m_lastOnSame = !forceClick && (m_current == oldCurrent) && oldWasSelected;
// Set the flag telling us whether the next click on this item should
// start editing its label. This should happen if we clicked on the
// current item and it was already selected, i.e. if this click was not
// done to select it.
//
// It should not happen if this was a double click (forceClick is true)
// nor if we hadn't had the focus before as then this click was used to
// give focus to the control.
m_lastOnSame = (m_current == oldCurrent) && oldWasSelected &&
!forceClick && HasFocus();
}
}