From: Vadim Zeitlin Date: Thu, 5 Jul 2007 22:44:33 +0000 (+0000) Subject: don't allow selecting multiple items in single selection control by changing the... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a9aead31d6c260600f8a292345755f7a86a53e35 don't allow selecting multiple items in single selection control by changing the focused item with Ctrl-arrows and then pressing Space git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47175 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/listctrl.cpp b/src/generic/listctrl.cpp index f5dfcd66b0..643b67245c 100644 --- a/src/generic/listctrl.cpp +++ b/src/generic/listctrl.cpp @@ -2462,7 +2462,7 @@ wxRect wxListMainWindow::GetLineLabelRect(size_t line) const image_x = 3 + ix + IMAGE_MARGIN_IN_REPORT_MODE; } } - + wxRect rect; rect.x = HEADER_OFFSET_X; rect.y = GetLineY(line); @@ -3161,7 +3161,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event ) wxRect label = GetLineLabelRect( current ); if (label.Contains( x, y )) m_renameTimer->Start( 250, true ); - + } else m_renameTimer->Start( 250, true ); @@ -3332,7 +3332,8 @@ void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event) else // !shift { // all previously selected items are unselected unless ctrl is held - if ( !event.ControlDown() ) + // in a multiselection control + if ( !event.ControlDown() || IsSingleSel() ) HighlightAll(false); ChangeCurrent(newCurrent); @@ -3340,10 +3341,9 @@ void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event) // refresh the old focus to remove it RefreshLine( oldCurrent ); - if ( !event.ControlDown() ) - { + // in single selection mode we must always have a selected item + if ( !event.ControlDown() || IsSingleSel() ) HighlightLine( m_current, true ); - } } RefreshLine( m_current ); @@ -3523,17 +3523,19 @@ void wxListMainWindow::OnChar( wxKeyEvent &event ) case WXK_SPACE: if ( IsSingleSel() ) { - SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED ); - - if ( IsHighlighted(m_current) ) + if ( event.ControlDown() ) + { + ReverseHighlight(m_current); + } + else // normal space press { - // don't unselect the item in single selection mode - break; + SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED ); } - //else: select it in ReverseHighlight() below if unselected } - - ReverseHighlight(m_current); + else // multiple selection + { + ReverseHighlight(m_current); + } break; case WXK_RETURN: @@ -4830,7 +4832,7 @@ void wxListMainWindow::OnScroll(wxScrollWinEvent& event) // update our idea of which lines are shown when we redraw the window the // next time ResetVisibleLinesRange(); - + if ( event.GetOrientation() == wxHORIZONTAL && HasHeader() ) { wxGenericListCtrl* lc = GetListCtrl();