prevent a single selection control from having multiple selected items [backport of 47175 and 47176 from trunk]
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@47177 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -3332,7 +3332,8 @@ void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event)
|
|||||||
else // !shift
|
else // !shift
|
||||||
{
|
{
|
||||||
// all previously selected items are unselected unless ctrl is held
|
// all previously selected items are unselected unless ctrl is held
|
||||||
if ( !event.ControlDown() )
|
// in a multiselection control
|
||||||
|
if ( !event.ControlDown() || IsSingleSel() )
|
||||||
HighlightAll(false);
|
HighlightAll(false);
|
||||||
|
|
||||||
ChangeCurrent(newCurrent);
|
ChangeCurrent(newCurrent);
|
||||||
@@ -3340,10 +3341,9 @@ void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event)
|
|||||||
// refresh the old focus to remove it
|
// refresh the old focus to remove it
|
||||||
RefreshLine( oldCurrent );
|
RefreshLine( oldCurrent );
|
||||||
|
|
||||||
if ( !event.ControlDown() )
|
// in single selection mode we must always have a selected item
|
||||||
{
|
if ( !event.ControlDown() || IsSingleSel() )
|
||||||
HighlightLine( m_current, true );
|
HighlightLine( m_current, true );
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshLine( m_current );
|
RefreshLine( m_current );
|
||||||
@@ -3523,17 +3523,19 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
case WXK_SPACE:
|
case WXK_SPACE:
|
||||||
if ( IsSingleSel() )
|
if ( IsSingleSel() )
|
||||||
{
|
{
|
||||||
SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
|
if ( event.ControlDown() )
|
||||||
|
|
||||||
if ( IsHighlighted(m_current) )
|
|
||||||
{
|
{
|
||||||
// don't unselect the item in single selection mode
|
ReverseHighlight(m_current);
|
||||||
break;
|
}
|
||||||
|
else // normal space press
|
||||||
|
{
|
||||||
|
SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
|
||||||
}
|
}
|
||||||
//else: select it in ReverseHighlight() below if unselected
|
|
||||||
}
|
}
|
||||||
|
else // multiple selection
|
||||||
ReverseHighlight(m_current);
|
{
|
||||||
|
ReverseHighlight(m_current);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
@@ -4808,6 +4810,11 @@ int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData
|
|||||||
|
|
||||||
void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data )
|
void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data )
|
||||||
{
|
{
|
||||||
|
// selections won't make sense any more after sorting the items so reset
|
||||||
|
// them
|
||||||
|
HighlightAll(false);
|
||||||
|
ResetCurrent();
|
||||||
|
|
||||||
list_ctrl_compare_func_2 = fn;
|
list_ctrl_compare_func_2 = fn;
|
||||||
list_ctrl_compare_data = data;
|
list_ctrl_compare_data = data;
|
||||||
m_lines.Sort( list_ctrl_compare_func_1 );
|
m_lines.Sort( list_ctrl_compare_func_1 );
|
||||||
|
Reference in New Issue
Block a user