Improve keyboard-only use of Footprint Viewer.
Fixes: lp:1465295 * https://bugs.launchpad.net/kicad/+bug/1465295
This commit is contained in:
parent
d094934cf4
commit
3fefe01d2e
|
@ -85,6 +85,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
|
||||||
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton )
|
EVT_UPDATE_UI( ID_ADD_FOOTPRINT_TO_BOARD, FOOTPRINT_VIEWER_FRAME::OnUpdateFootprintButton )
|
||||||
|
|
||||||
EVT_TEXT( ID_MODVIEW_LIB_FILTER, FOOTPRINT_VIEWER_FRAME::OnLibFilter )
|
EVT_TEXT( ID_MODVIEW_LIB_FILTER, FOOTPRINT_VIEWER_FRAME::OnLibFilter )
|
||||||
|
EVT_CHAR_HOOK( FOOTPRINT_VIEWER_FRAME::OnCharHook )
|
||||||
EVT_TEXT( ID_MODVIEW_FOOTPRINT_FILTER, FOOTPRINT_VIEWER_FRAME::OnFPFilter )
|
EVT_TEXT( ID_MODVIEW_FOOTPRINT_FILTER, FOOTPRINT_VIEWER_FRAME::OnFPFilter )
|
||||||
|
|
||||||
// listbox events
|
// listbox events
|
||||||
|
@ -336,20 +337,27 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateLibraryList()
|
||||||
// Search for a previous selection:
|
// Search for a previous selection:
|
||||||
int index = m_libList->FindString( getCurNickname(), true );
|
int index = m_libList->FindString( getCurNickname(), true );
|
||||||
|
|
||||||
if( index != wxNOT_FOUND )
|
if( index == wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
m_libList->SetSelection( index, true );
|
if( m_libList->GetCount() > 0 )
|
||||||
|
{
|
||||||
|
m_libList->SetSelection( 0 );
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
ClickOnLibList( dummy );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setCurNickname( wxEmptyString );
|
||||||
|
setCurFootprintName( wxEmptyString );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// If not found, clear current library selection because it can be
|
m_libList->SetSelection( index, true );
|
||||||
// deleted after a configuration change.
|
wxCommandEvent dummy;
|
||||||
setCurNickname( wxEmptyString );
|
ClickOnLibList( dummy );
|
||||||
setCurFootprintName( wxEmptyString );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReCreateFootprintList();
|
|
||||||
|
|
||||||
GetCanvas()->Refresh();
|
GetCanvas()->Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +423,16 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
|
||||||
int index = m_fpList->FindString( getCurFootprintName(), true );
|
int index = m_fpList->FindString( getCurFootprintName(), true );
|
||||||
|
|
||||||
if( index == wxNOT_FOUND )
|
if( index == wxNOT_FOUND )
|
||||||
setCurFootprintName( wxEmptyString );
|
{
|
||||||
|
if( m_fpList->GetCount() > 0 )
|
||||||
|
{
|
||||||
|
m_fpList->SetSelection( 0 );
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
ClickOnFootprintList( dummy );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
setCurFootprintName( wxEmptyString );
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_fpList->SetSelection( index, true );
|
m_fpList->SetSelection( index, true );
|
||||||
|
@ -444,6 +461,72 @@ void FOOTPRINT_VIEWER_FRAME::OnFPFilter( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_VIEWER_FRAME::OnCharHook( wxKeyEvent& aEvent )
|
||||||
|
{
|
||||||
|
if( aEvent.GetKeyCode() == WXK_UP )
|
||||||
|
{
|
||||||
|
if( m_libFilter->HasFocus() )
|
||||||
|
selectPrev( m_libList );
|
||||||
|
else
|
||||||
|
selectPrev( m_fpList );
|
||||||
|
}
|
||||||
|
else if( aEvent.GetKeyCode() == WXK_DOWN )
|
||||||
|
{
|
||||||
|
if( m_libFilter->HasFocus() )
|
||||||
|
selectNext( m_libList );
|
||||||
|
else
|
||||||
|
selectNext( m_fpList );
|
||||||
|
}
|
||||||
|
else if( aEvent.GetKeyCode() == WXK_TAB && m_libFilter->HasFocus() )
|
||||||
|
{
|
||||||
|
m_fpFilter->SetFocus();
|
||||||
|
}
|
||||||
|
else if( aEvent.GetKeyCode() == WXK_RETURN && m_fpList->GetSelection() >= 0 )
|
||||||
|
{
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
AddFootprintToPCB( dummy );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
aEvent.Skip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_VIEWER_FRAME::selectPrev( wxListBox* aListBox )
|
||||||
|
{
|
||||||
|
int prev = aListBox->GetSelection() - 1;
|
||||||
|
|
||||||
|
if( prev >= 0 )
|
||||||
|
{
|
||||||
|
aListBox->SetSelection( prev );
|
||||||
|
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
|
||||||
|
if( aListBox == m_libList )
|
||||||
|
ClickOnLibList( dummy );
|
||||||
|
else
|
||||||
|
ClickOnFootprintList( dummy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void FOOTPRINT_VIEWER_FRAME::selectNext( wxListBox* aListBox )
|
||||||
|
{
|
||||||
|
int next = aListBox->GetSelection() + 1;
|
||||||
|
|
||||||
|
if( next < aListBox->GetCount() )
|
||||||
|
{
|
||||||
|
aListBox->SetSelection( next );
|
||||||
|
|
||||||
|
wxCommandEvent dummy;
|
||||||
|
|
||||||
|
if( aListBox == m_libList )
|
||||||
|
ClickOnLibList( dummy );
|
||||||
|
else
|
||||||
|
ClickOnFootprintList( dummy );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
|
void FOOTPRINT_VIEWER_FRAME::ClickOnLibList( wxCommandEvent& aEvent )
|
||||||
{
|
{
|
||||||
int ii = m_libList->GetSelection();
|
int ii = m_libList->GetSelection();
|
||||||
|
@ -494,12 +577,11 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
|
||||||
}
|
}
|
||||||
catch( const IO_ERROR& ioe )
|
catch( const IO_ERROR& ioe )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format( _( "Could not load footprint '%s' from library '%s'."
|
||||||
_( "Could not load footprint \"%s\" from library \"%s\".\n\nError %s." ),
|
"\n\n%s" ),
|
||||||
GetChars( getCurFootprintName() ),
|
getCurFootprintName(),
|
||||||
GetChars( getCurNickname() ),
|
getCurNickname(),
|
||||||
GetChars( ioe.What() ) );
|
ioe.Problem() );
|
||||||
|
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -716,7 +798,10 @@ bool FOOTPRINT_VIEWER_FRAME::ShowModal( wxString* aFootprint, wxWindow* aParent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return KIWAY_PLAYER::ShowModal( aFootprint, aParent );
|
bool retval = KIWAY_PLAYER::ShowModal( aFootprint, aParent );
|
||||||
|
|
||||||
|
m_libFilter->SetFocus();
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -118,7 +118,10 @@ private:
|
||||||
|
|
||||||
void OnLibFilter( wxCommandEvent& aEvent );
|
void OnLibFilter( wxCommandEvent& aEvent );
|
||||||
void OnFPFilter( wxCommandEvent& aEvent );
|
void OnFPFilter( wxCommandEvent& aEvent );
|
||||||
|
void OnCharHook( wxKeyEvent& aEvent );
|
||||||
|
|
||||||
|
void selectPrev( wxListBox* aListBox );
|
||||||
|
void selectNext( wxListBox* aListBox );
|
||||||
void ClickOnLibList( wxCommandEvent& aEvent );
|
void ClickOnLibList( wxCommandEvent& aEvent );
|
||||||
void ClickOnFootprintList( wxCommandEvent& aEvent );
|
void ClickOnFootprintList( wxCommandEvent& aEvent );
|
||||||
void DClickOnFootprintList( wxCommandEvent& aEvent );
|
void DClickOnFootprintList( wxCommandEvent& aEvent );
|
||||||
|
|
Loading…
Reference in New Issue