send selection events when Ctrl-clicking an item repeeatedly in a multiselection tree
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45392 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -95,11 +95,6 @@ static inline void UnselectItem(HWND hwndTV, HTREEITEM htItem)
|
|||||||
SelectItem(hwndTV, htItem, false);
|
SelectItem(hwndTV, htItem, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void ToggleItemSelection(HWND hwndTV, HTREEITEM htItem)
|
|
||||||
{
|
|
||||||
SelectItem(hwndTV, htItem, !IsItemSelected(hwndTV, htItem));
|
|
||||||
}
|
|
||||||
|
|
||||||
// helper function which selects all items in a range and, optionally,
|
// helper function which selects all items in a range and, optionally,
|
||||||
// unselects all others
|
// unselects all others
|
||||||
static void SelectRange(HWND hwndTV,
|
static void SelectRange(HWND hwndTV,
|
||||||
@@ -168,15 +163,18 @@ static void SelectRange(HWND hwndTV,
|
|||||||
// helper function which tricks the standard control into changing the focused
|
// helper function which tricks the standard control into changing the focused
|
||||||
// item without changing anything else (if someone knows why Microsoft doesn't
|
// item without changing anything else (if someone knows why Microsoft doesn't
|
||||||
// allow to do it by just setting TVIS_FOCUSED flag, please tell me!)
|
// allow to do it by just setting TVIS_FOCUSED flag, please tell me!)
|
||||||
static void SetFocus(HWND hwndTV, HTREEITEM htItem)
|
//
|
||||||
|
// returns true if the focus was changed, false if the given item was already
|
||||||
|
// the focused one
|
||||||
|
static bool SetFocus(HWND hwndTV, HTREEITEM htItem)
|
||||||
{
|
{
|
||||||
// the current focus
|
// the current focus
|
||||||
HTREEITEM htFocus = (HTREEITEM)TreeView_GetSelection(hwndTV);
|
HTREEITEM htFocus = (HTREEITEM)TreeView_GetSelection(hwndTV);
|
||||||
|
|
||||||
|
if ( htItem == htFocus )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( htItem )
|
if ( htItem )
|
||||||
{
|
|
||||||
// set the focus
|
|
||||||
if ( htItem != htFocus )
|
|
||||||
{
|
{
|
||||||
// remember the selection state of the item
|
// remember the selection state of the item
|
||||||
bool wasSelected = IsItemSelected(hwndTV, htItem);
|
bool wasSelected = IsItemSelected(hwndTV, htItem);
|
||||||
@@ -200,11 +198,7 @@ static void SetFocus(HWND hwndTV, HTREEITEM htItem)
|
|||||||
}
|
}
|
||||||
//else: was selected, still selected - ok
|
//else: was selected, still selected - ok
|
||||||
}
|
}
|
||||||
//else: nothing to do, focus already there
|
else // reset focus
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( htFocus )
|
|
||||||
{
|
{
|
||||||
bool wasFocusSelected = IsItemSelected(hwndTV, htFocus);
|
bool wasFocusSelected = IsItemSelected(hwndTV, htFocus);
|
||||||
|
|
||||||
@@ -217,8 +211,8 @@ static void SetFocus(HWND hwndTV, HTREEITEM htItem)
|
|||||||
SelectItem(hwndTV, htFocus);
|
SelectItem(hwndTV, htFocus);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//else: nothing to do, no focus already
|
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -1669,23 +1663,13 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select)
|
|||||||
{
|
{
|
||||||
wxCHECK_RET( !IsHiddenRoot(item), _T("can't select hidden root item") );
|
wxCHECK_RET( !IsHiddenRoot(item), _T("can't select hidden root item") );
|
||||||
|
|
||||||
if ( m_windowStyle & wxTR_MULTIPLE )
|
wxASSERT_MSG( select || HasFlag(wxTR_MULTIPLE),
|
||||||
{
|
|
||||||
::SelectItem(GetHwnd(), HITEM(item), select);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxASSERT_MSG( select,
|
|
||||||
_T("SelectItem(false) works only for multiselect") );
|
_T("SelectItem(false) works only for multiselect") );
|
||||||
|
|
||||||
// inspite of the docs (MSDN Jan 99 edition), we don't seem to receive
|
|
||||||
// the notification from the control (i.e. TVN_SELCHANG{ED|ING}), so
|
|
||||||
// send them ourselves
|
|
||||||
|
|
||||||
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
|
wxTreeEvent event(wxEVT_COMMAND_TREE_SEL_CHANGING, this, item);
|
||||||
if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
|
if ( !GetEventHandler()->ProcessEvent(event) || event.IsAllowed() )
|
||||||
{
|
{
|
||||||
if ( !TreeView_SelectItem(GetHwnd(), HITEM(item)) )
|
if ( !::SelectItem(GetHwnd(), HITEM(item), select) )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("TreeView_SelectItem"));
|
wxLogLastError(wxT("TreeView_SelectItem"));
|
||||||
}
|
}
|
||||||
@@ -1697,7 +1681,6 @@ void wxTreeCtrl::SelectItem(const wxTreeItemId& item, bool select)
|
|||||||
}
|
}
|
||||||
//else: program vetoed the change
|
//else: program vetoed the change
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item)
|
void wxTreeCtrl::EnsureVisible(const wxTreeItemId& item)
|
||||||
{
|
{
|
||||||
@@ -2013,7 +1996,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
|
|||||||
SetFocus();
|
SetFocus();
|
||||||
|
|
||||||
// toggle selected state
|
// toggle selected state
|
||||||
::ToggleItemSelection(GetHwnd(), htItem);
|
ToggleItemSelection(htItem);
|
||||||
|
|
||||||
::SetFocus(GetHwnd(), htItem);
|
::SetFocus(GetHwnd(), htItem);
|
||||||
|
|
||||||
@@ -2209,7 +2192,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
|
|||||||
case VK_SPACE:
|
case VK_SPACE:
|
||||||
if ( bCtrl )
|
if ( bCtrl )
|
||||||
{
|
{
|
||||||
::ToggleItemSelection(GetHwnd(), htSel);
|
ToggleItemSelection(htSel);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user