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:
@@ -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