From 8d206d6a67984d0171690c4153f0935e2b257d6b Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 12 Apr 2023 08:12:22 +0200 Subject: [PATCH] LIB_TABLE_GRID_TRICKS, popup context menu: fix minor issues: - add separator only if needed - ensure selection parameters are up to date. --- common/lib_table_grid_tricks.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/lib_table_grid_tricks.cpp b/common/lib_table_grid_tricks.cpp index 56e49bfe38..fec55799c7 100644 --- a/common/lib_table_grid_tricks.cpp +++ b/common/lib_table_grid_tricks.cpp @@ -1,7 +1,7 @@ /* * This program source code file is part of KiCad, a free EDA CAD application. * - * Copyright (C) 2017-2022 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2017-2023 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -24,12 +24,16 @@ LIB_TABLE_GRID_TRICKS::LIB_TABLE_GRID_TRICKS( WX_GRID* aGrid ) : GRID_TRICKS( aG { } + void LIB_TABLE_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) { bool showActivate = false; bool showDeactivate = false; LIB_TABLE_GRID* tbl = static_cast( m_grid->GetTable() ); + // Ensure selection parameters are up to date + getSelectedArea(); + for( int row = m_sel_row_start; row < m_sel_row_start + m_sel_row_count; ++row ) { if( tbl->GetValueAsBool( row, 0 ) ) @@ -47,10 +51,13 @@ void LIB_TABLE_GRID_TRICKS::showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) if( showDeactivate ) menu.Append( LIB_TABLE_GRID_TRICKS_DEACTIVATE_SELECTED, _( "Deactivate selected" ) ); - menu.AppendSeparator(); + if( showActivate || showDeactivate ) + menu.AppendSeparator(); + GRID_TRICKS::showPopupMenu( menu, aEvent ); } + void LIB_TABLE_GRID_TRICKS::doPopupSelection( wxCommandEvent& event ) { int menu_id = event.GetId();