From 21eea1f56718c3b9e7fba6a3db551b99ea6d8e06 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 25 Aug 2018 15:29:00 +0100 Subject: [PATCH] Remove HasFocus() checks (which don't work on all platforms) in favour of row highlighting which is visible without focus. Fixes: lp:1788873 * https://bugs.launchpad.net/kicad/+bug/1788873 --- common/dialogs/dialog_configure_paths.cpp | 8 ++------ pcbnew/dialogs/dialog_fp_plugin_options.cpp | 11 +++++------ pcbnew/dialogs/panel_setup_netclasses.cpp | 15 +++++++++++---- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/common/dialogs/dialog_configure_paths.cpp b/common/dialogs/dialog_configure_paths.cpp index 6e35d63ac8..0d4e0304f7 100644 --- a/common/dialogs/dialog_configure_paths.cpp +++ b/common/dialogs/dialog_configure_paths.cpp @@ -374,13 +374,9 @@ void DIALOG_CONFIGURE_PATHS::OnRemoveEnvVar( wxCommandEvent& event ) { int curRow = m_EnvVars->GetGridCursorRow(); - if( !m_EnvVars->HasFocus() || curRow < 0 ) - { - m_EnvVars->SetFocus(); + if( curRow < 0 ) return; - } - - if( IsEnvVarImmutable( m_EnvVars->GetCellValue( curRow, EV_NAME_COL ) ) ) + else if( IsEnvVarImmutable( m_EnvVars->GetCellValue( curRow, EV_NAME_COL ) ) ) { wxBell(); return; diff --git a/pcbnew/dialogs/dialog_fp_plugin_options.cpp b/pcbnew/dialogs/dialog_fp_plugin_options.cpp index 028a87c4d5..9fe65ee170 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options.cpp +++ b/pcbnew/dialogs/dialog_fp_plugin_options.cpp @@ -61,6 +61,11 @@ public: { SetTitle( wxString::Format( _( "Options for Library \"%s\"" ), aNickname ) ); + // Give a bit more room for combobox editors + m_grid->SetDefaultRowSize( m_grid->GetDefaultRowSize() + 4 ); + + m_grid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); + // add Cut, Copy, and Paste to wxGrid m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); @@ -243,12 +248,6 @@ private: if( !m_grid->CommitPendingChanges() ) return; - if( !m_grid->HasFocus() ) - { - m_grid->SetFocus(); - return; - } - int curRow = m_grid->GetGridCursorRow(); m_grid->DeleteRows( curRow ); diff --git a/pcbnew/dialogs/panel_setup_netclasses.cpp b/pcbnew/dialogs/panel_setup_netclasses.cpp index 75720f33e2..e68a77f2b1 100644 --- a/pcbnew/dialogs/panel_setup_netclasses.cpp +++ b/pcbnew/dialogs/panel_setup_netclasses.cpp @@ -73,6 +73,12 @@ PANEL_SETUP_NETCLASSES::PANEL_SETUP_NETCLASSES( PAGED_DIALOG* aParent, PCB_EDIT_ m_netclassGrid->SetDefaultRowSize( m_netclassGrid->GetDefaultRowSize() + 4 ); m_membershipGrid->SetDefaultRowSize( m_membershipGrid->GetDefaultRowSize() + 4 ); + m_netclassGrid->PushEventHandler( new GRID_TRICKS( m_netclassGrid ) ); + m_membershipGrid->PushEventHandler( new GRID_TRICKS( m_membershipGrid ) ); + + m_netclassGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); + m_membershipGrid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows ); + // Set up the net name column of the netclass membership grid to read-only wxGridCellAttr* attr = new wxGridCellAttr; attr->SetReadOnly( true ); @@ -92,6 +98,10 @@ PANEL_SETUP_NETCLASSES::~PANEL_SETUP_NETCLASSES() { delete [] m_originalColWidths; + // Delete the GRID_TRICKS. + m_netclassGrid->PopEventHandler( true ); + m_membershipGrid->PopEventHandler( true ); + m_netclassGrid->Disconnect( wxEVT_GRID_CELL_CHANGING, wxGridEventHandler( PANEL_SETUP_NETCLASSES::OnNetclassGridCellChanging ), NULL, this ); } @@ -327,11 +337,8 @@ void PANEL_SETUP_NETCLASSES::OnRemoveNetclassClick( wxCommandEvent& event ) int curRow = m_netclassGrid->GetGridCursorRow(); - if( !m_netclassGrid->HasFocus() || curRow < 0 ) - { - m_netclassGrid->SetFocus(); + if( curRow < 0 ) return; - } else if( curRow == 0 ) { DisplayErrorMessage( this, _( "The default net class is required." ) );