From ff118c62ec89fa15349a83f0f4550e03c4dc17c2 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 27 Aug 2019 07:42:43 -0700 Subject: [PATCH] Cleanup OnCharHook in footprint_viewer_frame This provides a better fix for d0adaf1ef and handles Tab/Shift-Tab consistently in the filters --- pcbnew/footprint_viewer_frame.cpp | 40 +++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 0b7e2687b0..3c0b3c9461 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -466,29 +466,45 @@ void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent ) { if( aEvent.GetKeyCode() == WXK_UP ) { - if( m_libFilter->HasFocus() ) + wxWindow* focused = FindFocus(); + + if( m_libFilter->HasFocus() || m_libList->HasFocus() ) selectPrev( m_libList ); else selectPrev( m_fpList ); + + // Need to reset the focus after selection due to GTK mouse-refresh + // that captures the mouse into the canvas to update scrollbars + if( focused ) + focused->SetFocus(); } else if( aEvent.GetKeyCode() == WXK_DOWN ) { + wxWindow* focused = FindFocus(); + + if( m_libFilter->HasFocus() || m_libList->HasFocus() ) + selectNext( m_libList ); + else + selectNext( m_fpList ); + // Need to reset the focus after selection due to GTK mouse-refresh // that captures the mouse into the canvas to update scrollbars - if( m_libFilter->HasFocus() ) - { - selectNext( m_libList ); - m_libFilter->SetFocus(); - } - else - { - selectNext( m_fpList ); - m_fpList->SetFocus(); - } + if( focused ) + focused->SetFocus(); } else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() ) { - m_fpFilter->SetFocus(); + if( !aEvent.ShiftDown() ) + m_fpFilter->SetFocus(); + else + aEvent.Skip(); + } + else if( aEvent.GetKeyCode() == WXK_TAB && m_fpFilter->HasFocus() ) + { + if( aEvent.ShiftDown() ) + m_libFilter->SetFocus(); + else + aEvent.Skip(); } else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 ) {