Cleanup OnCharHook in footprint_viewer_frame

This provides a better fix for d0adaf1ef and handles Tab/Shift-Tab
consistently in the filters
This commit is contained in:
Seth Hillbrand 2019-08-27 07:42:43 -07:00
parent d0adaf1efd
commit ff118c62ec
1 changed files with 28 additions and 12 deletions

View File

@ -466,29 +466,45 @@ void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
{ {
if( aEvent.GetKeyCode() == WXK_UP ) if( aEvent.GetKeyCode() == WXK_UP )
{ {
if( m_libFilter->HasFocus() ) wxWindow* focused = FindFocus();
if( m_libFilter->HasFocus() || m_libList->HasFocus() )
selectPrev( m_libList ); selectPrev( m_libList );
else else
selectPrev( m_fpList ); 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 ) 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 // Need to reset the focus after selection due to GTK mouse-refresh
// that captures the mouse into the canvas to update scrollbars // that captures the mouse into the canvas to update scrollbars
if( m_libFilter->HasFocus() ) if( focused )
{ focused->SetFocus();
selectNext( m_libList );
m_libFilter->SetFocus();
}
else
{
selectNext( m_fpList );
m_fpList->SetFocus();
}
} }
else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() ) else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
{ {
if( !aEvent.ShiftDown() )
m_fpFilter->SetFocus(); 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 ) else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
{ {