Handle list double-click without shortcuts

The LIST_DCLICK event can be fired by spacebar or enter in GTK.  This
conflicts with using the spacebar to reset local coordinates.  Instead,
we capture the double-click event manually to add the footprint to the
board

Fixes https://gitlab.com/kicad/code/kicad/issues/5714

Fixes https://gitlab.com/kicad/code/kicad/issues/10633

(cherry picked from commit ff6f398607)
This commit is contained in:
Seth Hillbrand 2022-02-25 16:51:28 -08:00
parent 535ea800c0
commit c9746fb34b
2 changed files with 7 additions and 4 deletions

View File

@ -92,7 +92,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME )
// listbox events // listbox events
EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList ) EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList )
EVT_LISTBOX( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList ) EVT_LISTBOX( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList )
EVT_LISTBOX_DCLICK( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList )
END_EVENT_TABLE() END_EVENT_TABLE()
@ -172,6 +171,8 @@ FOOTPRINT_VIEWER_FRAME::FOOTPRINT_VIEWER_FRAME( KIWAY* aKiway, wxWindow* aParent
m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize, m_fpList = new wxListBox( fpPanel, ID_MODVIEW_FOOTPRINT_LIST, wxDefaultPosition, wxDefaultSize,
0, nullptr, wxLB_HSCROLL | wxNO_BORDER ); 0, nullptr, wxLB_HSCROLL | wxNO_BORDER );
m_fpList->Connect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ), nullptr, this );
fpSizer->Add( m_fpList, 1, wxEXPAND, 5 ); fpSizer->Add( m_fpList, 1, wxEXPAND, 5 );
fpPanel->SetSizer( fpSizer ); fpPanel->SetSizer( fpSizer );
@ -301,6 +302,7 @@ FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME()
GetCanvas()->GetView()->Clear(); GetCanvas()->GetView()->Clear();
// Be sure any event cannot be fired after frame deletion: // Be sure any event cannot be fired after frame deletion:
GetCanvas()->SetEvtHandlerEnabled( false ); GetCanvas()->SetEvtHandlerEnabled( false );
m_fpList->Disconnect( wxEVT_LEFT_DCLICK, wxMouseEventHandler( FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ), nullptr, this );
} }
@ -687,9 +689,10 @@ void FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList( wxCommandEvent& aEvent )
} }
void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxCommandEvent& aEvent ) void FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList( wxMouseEvent& aEvent )
{ {
AddFootprintToPCB( aEvent ); wxCommandEvent evt;
AddFootprintToPCB( evt );
} }

View File

@ -122,7 +122,7 @@ private:
void selectNext( 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( wxMouseEvent& aEvent );
void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void LoadSettings( APP_SETTINGS_BASE* aCfg ) override;
void SaveSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;