From f14ba983d6de9cf2edf880a517b1542bc54151da Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 24 Jul 2025 11:47:17 -0700 Subject: [PATCH] Allow scrolling by keyboard in search panel Lets you quickly scroll through elements in the board, zooming and selecting each --- common/widgets/search_pane_tab.cpp | 99 ++++++++++++++++++++++++------ 1 file changed, 79 insertions(+), 20 deletions(-) diff --git a/common/widgets/search_pane_tab.cpp b/common/widgets/search_pane_tab.cpp index d57bf01b25..c044a3c616 100644 --- a/common/widgets/search_pane_tab.cpp +++ b/common/widgets/search_pane_tab.cpp @@ -151,40 +151,99 @@ void SEARCH_PANE_LISTVIEW::OnColClicked( wxListEvent& aEvent ) void SEARCH_PANE_LISTVIEW::OnChar( wxKeyEvent& aEvent ) { - if( aEvent.GetKeyCode() == WXK_CONTROL_A ) + switch( aEvent.GetKeyCode() ) { - // Select All - for( int row = 0; row < GetItemCount(); row++ ) - SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); - } - else if( aEvent.GetKeyCode() == WXK_CONTROL_C ) - { - // Copy to clipboard the selected rows - if( wxTheClipboard->Open() ) + case WXK_CONTROL_A: { - wxString txt; - + // Select All for( int row = 0; row < GetItemCount(); row++ ) + SetItemState( row, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED ); + + break; + } + + case WXK_CONTROL_C: + { + // Copy to clipboard the selected rows + if( wxTheClipboard->Open() ) { - if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED ) + wxString txt; + + for( int row = 0; row < GetItemCount(); row++ ) { - for( int col = 0; col < GetColumnCount(); col++ ) + if( GetItemState( row, wxLIST_STATE_SELECTED ) == wxLIST_STATE_SELECTED ) { - if( GetColumnWidth( col ) > 0 ) + for( int col = 0; col < GetColumnCount(); col++ ) { - txt += GetItemText( row, col ); + if( GetColumnWidth( col ) > 0 ) + { + txt += GetItemText( row, col ); - if( row <= GetItemCount() - 1 ) - txt += wxT( "\t" ); + if( row <= GetItemCount() - 1 ) + txt += wxT( "\t" ); + } } + + txt += wxT( "\n" ); } + } + + wxTheClipboard->SetData( new wxTextDataObject( txt ) ); + wxTheClipboard->Close(); + } + + break; + } - txt += wxT( "\n" ); + case WXK_DOWN: + case WXK_NUMPAD_DOWN: + { + // Move selection down + long focused = GetFocusedItem(); + if( focused < 0 ) + focused = 0; + + if( focused < GetItemCount() - 1 ) + { + if( !(aEvent.GetModifiers() & wxMOD_SHIFT) ) + { + int next = -1; + + while( ( next = GetNextSelected( next ) ) != wxNOT_FOUND ) + Select( next, false ); } + + ++focused; + Focus( focused ); + Select( focused ); + } + break; + } + case WXK_UP: + case WXK_NUMPAD_UP: + { + // Move selection up + long focused = GetFocusedItem(); + + if( focused < 0 ) + focused = 0; + + if( focused > 0 ) + { + if( !(aEvent.GetModifiers() & wxMOD_SHIFT) ) + { + int next = -1; + + while( ( next = GetNextSelected( next ) ) != wxNOT_FOUND ) + Select( next, false ); + } + + --focused; + Focus( focused ); + Select( focused ); } - wxTheClipboard->SetData( new wxTextDataObject( txt ) ); - wxTheClipboard->Close(); + break; } } }