Hook up delete key in stackup materials list box

Allow the delete key to delete a material from the stackup list, since
otherwise there is no way to delete materials from the list.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16854
This commit is contained in:
Ian McInerney 2024-02-03 16:39:56 +00:00
parent 4146a74bb7
commit 7edda82b2a
5 changed files with 640 additions and 617 deletions

View File

@ -128,3 +128,12 @@ void DIALOG_DIELECTRIC_MATERIAL::onListItemSelected( wxListEvent& event )
m_tcEpsilonR->SetValue( m_materialList.GetSubstrate( idx )->FormatEpsilonR() );
m_tcLossTg->SetValue( m_materialList.GetSubstrate( idx )->FormatLossTangent() );
}
void DIALOG_DIELECTRIC_MATERIAL::onListKeyDown( wxListEvent& event )
{
int idx = event.GetIndex();
if( idx > 0 )
m_lcMaterials->DeleteItem( idx );
}

View File

@ -43,9 +43,10 @@ public:
DIELECTRIC_SUBSTRATE GetSelectedSubstrate();
private:
void onListItemSelected( wxListEvent& event ) override;
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
void onListKeyDown( wxListEvent& event ) override;
void onListItemSelected( wxListEvent& event ) override;
bool TransferDataFromWindow() override;
bool TransferDataToWindow() override;
void initMaterialList(); // Fills the dialog with available materials

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -85,11 +85,13 @@ DIALOG_DIELECTRIC_MATERIAL_BASE::DIALOG_DIELECTRIC_MATERIAL_BASE( wxWindow* pare
// Connect Events
m_lcMaterials->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_DIELECTRIC_MATERIAL_BASE::onListItemSelected ), NULL, this );
m_lcMaterials->Connect( wxEVT_COMMAND_LIST_KEY_DOWN, wxListEventHandler( DIALOG_DIELECTRIC_MATERIAL_BASE::onListKeyDown ), NULL, this );
}
DIALOG_DIELECTRIC_MATERIAL_BASE::~DIALOG_DIELECTRIC_MATERIAL_BASE()
{
// Disconnect Events
m_lcMaterials->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( DIALOG_DIELECTRIC_MATERIAL_BASE::onListItemSelected ), NULL, this );
m_lcMaterials->Disconnect( wxEVT_COMMAND_LIST_KEY_DOWN, wxListEventHandler( DIALOG_DIELECTRIC_MATERIAL_BASE::onListKeyDown ), NULL, this );
}

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.1-0-g8feb16b)
// C++ code generated with wxFormBuilder (version 4.0.0-0-g0efcecf-dirty)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -48,6 +48,7 @@ class DIALOG_DIELECTRIC_MATERIAL_BASE : public DIALOG_SHIM
// Virtual event handlers, override them in your derived class
virtual void onListItemSelected( wxListEvent& event ) { event.Skip(); }
virtual void onListKeyDown( wxListEvent& event ) { event.Skip(); }
public: