Improve hit detection in wxMSW wxTreeCtrl with wxTR_FULL_ROW_HIGHLIGHT style.
When wxTR_FULL_ROW_HIGHLIGHT is used, the item visually takes up the entire breadth of the window so clicking both to the left or to the right of the item should have the same effect as clicking on it. So add a MSWIsOnItem() helper which tests for whether a point is above the item correctly and use it in order to: 1. In multi selection mode, allow clicking anywhere to select the item(s) when Ctrl or Shift is pressed (Closes #11598). 2. Generate activation event when clicking to the right of the item too (Closes #11602). 3. Detect item bounds correctly in WM_LBUTTONUP handler (although it's not really clear what does this code do and hence what problem does this fix...). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63089 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -287,6 +287,14 @@ private:
|
||||
void ClearFocusedItem();
|
||||
void SetFocusedItem(const wxTreeItemId& item);
|
||||
|
||||
// check if the given flags (taken from TV_HITTESTINFO structure)
|
||||
// indicate a position "on item": this is less trivial than just checking
|
||||
// for TVHT_ONITEM because we consider that points to the left and right of
|
||||
// item text are also "on item" when wxTR_FULL_ROW_HIGHLIGHT is used as the
|
||||
// item visually spans the entire breadth of the window then
|
||||
bool MSWIsOnItem(unsigned flags) const;
|
||||
|
||||
|
||||
// the hash storing the items attributes (indexed by item ids)
|
||||
wxMapTreeAttr m_attrs;
|
||||
|
||||
|
@@ -2215,6 +2215,15 @@ bool wxTreeCtrl::MSWCommand(WXUINT cmd, WXWORD id_)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxTreeCtrl::MSWIsOnItem(unsigned flags) const
|
||||
{
|
||||
unsigned mask = TVHT_ONITEM;
|
||||
if ( HasFlag(wxTR_FULL_ROW_HIGHLIGHT) )
|
||||
mask |= TVHT_ONITEMINDENT | TVHT_ONITEMRIGHT;
|
||||
|
||||
return (flags & mask) != 0;
|
||||
}
|
||||
|
||||
bool wxTreeCtrl::MSWHandleSelectionKey(unsigned vkey)
|
||||
{
|
||||
const bool bCtrl = wxIsCtrlDown();
|
||||
@@ -2716,7 +2725,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
|
||||
m_htClickedItem.Unset();
|
||||
|
||||
if ( !(tvht.flags & TVHT_ONITEM) )
|
||||
if ( !MSWIsOnItem(tvht.flags) )
|
||||
{
|
||||
if ( tvht.flags & TVHT_ONITEMBUTTON )
|
||||
{
|
||||
@@ -3067,10 +3076,7 @@ wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
|
||||
}
|
||||
}
|
||||
|
||||
if ( !m_dragStarted &&
|
||||
(tvht.flags & TVHT_ONITEMSTATEICON ||
|
||||
tvht.flags & TVHT_ONITEMICON ||
|
||||
tvht.flags & TVHT_ONITEM) )
|
||||
if ( !m_dragStarted && MSWIsOnItem(tvht.flags) )
|
||||
{
|
||||
processed = true;
|
||||
}
|
||||
@@ -3652,7 +3658,7 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
||||
::ScreenToClient(GetHwnd(), &tvhti.pt);
|
||||
if ( TreeView_HitTest(GetHwnd(), &tvhti) )
|
||||
{
|
||||
if ( tvhti.flags & TVHT_ONITEM )
|
||||
if ( MSWIsOnItem(tvhti.flags) )
|
||||
{
|
||||
event.m_item = tvhti.hItem;
|
||||
eventType = (int)hdr->code == NM_DBLCLK
|
||||
|
Reference in New Issue
Block a user