Merge branch 'generic-treectrl-fixes'
Several improvements to generic wxTreeCtrl. See https://github.com/wxWidgets/wxWidgets/pull/1765
This commit is contained in:
@@ -357,6 +357,7 @@ void wxTreeCtrlBase::OnCharHook(wxKeyEvent& event)
|
|||||||
wxFALLTHROUGH;
|
wxFALLTHROUGH;
|
||||||
|
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
|
case WXK_NUMPAD_ENTER:
|
||||||
EndEditLabel(GetFocusedItem(), discardChanges);
|
EndEditLabel(GetFocusedItem(), discardChanges);
|
||||||
|
|
||||||
// Do not call Skip() below.
|
// Do not call Skip() below.
|
||||||
|
@@ -3081,8 +3081,8 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
|
|||||||
// ' ' | return : activate
|
// ' ' | return : activate
|
||||||
// up : go up (not last children!)
|
// up : go up (not last children!)
|
||||||
// down : go down
|
// down : go down
|
||||||
// left : go to parent
|
// left : collapse or go to parent
|
||||||
// right : open if parent and go next
|
// right : expand or go to first child
|
||||||
// home : go to root
|
// home : go to root
|
||||||
// end : go to last item without opening parents
|
// end : go to last item without opening parents
|
||||||
// alnum : start or continue searching for the item with this prefix
|
// alnum : start or continue searching for the item with this prefix
|
||||||
@@ -3210,28 +3210,57 @@ void wxGenericTreeCtrl::OnChar( wxKeyEvent &event )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// left arrow goes to the parent
|
// left arrow collapses or goes to the parent if it's not expanded
|
||||||
case WXK_LEFT:
|
case WXK_LEFT:
|
||||||
{
|
{
|
||||||
wxTreeItemId prev = GetItemParent( m_current );
|
if (m_current == GetRootItem().m_pItem && HasFlag(wxTR_HIDE_ROOT))
|
||||||
if ((prev == GetRootItem()) && HasFlag(wxTR_HIDE_ROOT))
|
|
||||||
{
|
{
|
||||||
// don't go to root if it is hidden
|
// don't try to collapse hidden root item
|
||||||
prev = GetPrevSibling( m_current );
|
// (which can be the current one when the tree is empty)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (prev)
|
if (IsExpanded(m_current))
|
||||||
{
|
{
|
||||||
DoSelectItem( prev, unselect_others, extended_select );
|
Collapse(m_current);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// select parent unless it's the hidden root
|
||||||
|
wxTreeItemId parent = GetItemParent(m_current);
|
||||||
|
if (parent && (parent != GetRootItem() || !HasFlag(wxTR_HIDE_ROOT)))
|
||||||
|
{
|
||||||
|
DoSelectItem(parent, unselect_others, extended_select);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// right arrow expands or goes to first child if it's already expanded
|
||||||
case WXK_RIGHT:
|
case WXK_RIGHT:
|
||||||
// right arrow just expand the item will be fine
|
{
|
||||||
if (m_current != GetRootItem().m_pItem || !HasFlag(wxTR_HIDE_ROOT))
|
if (m_current == GetRootItem().m_pItem && HasFlag(wxTR_HIDE_ROOT))
|
||||||
|
{
|
||||||
|
// don't try to expand hidden root item
|
||||||
|
// (which can be the current one when the tree is empty)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (HasChildren(m_current))
|
||||||
|
{
|
||||||
|
if (IsExpanded(m_current))
|
||||||
|
{
|
||||||
|
wxTreeItemIdValue cookie;
|
||||||
|
wxTreeItemId child = GetFirstChild(m_current, cookie);
|
||||||
|
if (child)
|
||||||
|
{
|
||||||
|
DoSelectItem(child, unselect_others, extended_select);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
Expand(m_current);
|
Expand(m_current);
|
||||||
//else: don't try to expand hidden root item (which can be the
|
}
|
||||||
// current one when the tree is empty)
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_DOWN:
|
case WXK_DOWN:
|
||||||
@@ -3789,20 +3818,21 @@ void wxGenericTreeCtrl::OnMouse( wxMouseEvent &event )
|
|||||||
GetEventHandler()->ProcessEvent(nevent);
|
GetEventHandler()->ProcessEvent(nevent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Don't deselect anything if we're just collapsing or expanding
|
||||||
|
// the item.
|
||||||
|
if ( !(flags & wxTREE_HITTEST_ONITEMBUTTON) )
|
||||||
|
{
|
||||||
// this facilitates multiple-item drag-and-drop
|
// this facilitates multiple-item drag-and-drop
|
||||||
|
if ( HasFlag(wxTR_MULTIPLE) &&
|
||||||
if ( /* item && */ HasFlag(wxTR_MULTIPLE))
|
!(event.CmdDown() || event.ShiftDown()) )
|
||||||
{
|
{
|
||||||
wxArrayTreeItemIds selections;
|
wxArrayTreeItemIds selections;
|
||||||
size_t count = GetSelections(selections);
|
if ( GetSelections(selections) > 1 )
|
||||||
|
|
||||||
if (count > 1 &&
|
|
||||||
!event.CmdDown() &&
|
|
||||||
!event.ShiftDown())
|
|
||||||
{
|
{
|
||||||
DoSelectItem(item, true, false);
|
DoSelectItem(item, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( m_lastOnSame )
|
if ( m_lastOnSame )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user