From c9746fb34bc866dd040e24e49a40aa894d9b3c31 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Fri, 25 Feb 2022 16:51:28 -0800 Subject: [PATCH] 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 ff6f398607cd703c04c63c842229db44c78f809f) --- pcbnew/footprint_viewer_frame.cpp | 9 ++++++--- pcbnew/footprint_viewer_frame.h | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pcbnew/footprint_viewer_frame.cpp b/pcbnew/footprint_viewer_frame.cpp index 1fb25565b3..2922978723 100644 --- a/pcbnew/footprint_viewer_frame.cpp +++ b/pcbnew/footprint_viewer_frame.cpp @@ -92,7 +92,6 @@ BEGIN_EVENT_TABLE( FOOTPRINT_VIEWER_FRAME, EDA_DRAW_FRAME ) // listbox events EVT_LISTBOX( ID_MODVIEW_LIB_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnLibList ) EVT_LISTBOX( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::ClickOnFootprintList ) - EVT_LISTBOX_DCLICK( ID_MODVIEW_FOOTPRINT_LIST, FOOTPRINT_VIEWER_FRAME::DClickOnFootprintList ) 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, 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 ); fpPanel->SetSizer( fpSizer ); @@ -301,6 +302,7 @@ FOOTPRINT_VIEWER_FRAME::~FOOTPRINT_VIEWER_FRAME() GetCanvas()->GetView()->Clear(); // Be sure any event cannot be fired after frame deletion: 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 ); } diff --git a/pcbnew/footprint_viewer_frame.h b/pcbnew/footprint_viewer_frame.h index cc6062ef7b..d05796b69d 100644 --- a/pcbnew/footprint_viewer_frame.h +++ b/pcbnew/footprint_viewer_frame.h @@ -122,7 +122,7 @@ private: void selectNext( wxListBox* aListBox ); void ClickOnLibList( wxCommandEvent& aEvent ); void ClickOnFootprintList( wxCommandEvent& aEvent ); - void DClickOnFootprintList( wxCommandEvent& aEvent ); + void DClickOnFootprintList( wxMouseEvent& aEvent ); void LoadSettings( APP_SETTINGS_BASE* aCfg ) override; void SaveSettings( APP_SETTINGS_BASE* aCfg ) override;