Handle excessive resize requests
For unknown reasons, GTK3 may send resize events when editing grid fields. This can cause the grid editor to exit, losing the focus and overwritting the characters at the next input. We avoid this by filtering the size events when the size doesn't change. Fixes: lp:1817810 * https://bugs.launchpad.net/kicad/+bug/1817810
This commit is contained in:
parent
22229fbba4
commit
13249b723b
|
@ -352,8 +352,8 @@ void GRID_TRICKS::onKeyDown( wxKeyEvent& ev )
|
|||
return;
|
||||
}
|
||||
|
||||
// shift-return for OK
|
||||
if( ev.GetKeyCode() == WXK_RETURN && ev.ShiftDown() )
|
||||
// shift-return (Mac default) or Ctrl-Return (GTK) for OK
|
||||
if( ev.GetKeyCode() == WXK_RETURN && ( ev.ShiftDown() || ev.ControlDown() ) )
|
||||
{
|
||||
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
|
||||
return;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2004-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 2004-2019 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
|
||||
|
@ -60,6 +60,7 @@ DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::DIALOG_EDIT_COMPONENT_IN_SCHEMATIC( SCH_EDIT
|
|||
m_part = GetParent()->GetLibPart( m_cmp->GetLibId(), true );
|
||||
m_fields = new FIELDS_GRID_TABLE<SCH_FIELD>( this, aParent, m_part );
|
||||
|
||||
m_width = 0;
|
||||
m_delayedFocusRow = REFERENCE;
|
||||
m_delayedFocusColumn = FDC_VALUE;
|
||||
|
||||
|
@ -634,6 +635,7 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::UpdateFieldsFromLibrary( wxCommandEvent
|
|||
|
||||
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::AdjustGridColumns( int aWidth )
|
||||
{
|
||||
m_width = aWidth;
|
||||
// Account for scroll bars
|
||||
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
|
||||
|
||||
|
@ -679,9 +681,13 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnUpdateUI( wxUpdateUIEvent& event )
|
|||
|
||||
void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnSizeGrid( wxSizeEvent& event )
|
||||
{
|
||||
AdjustGridColumns( event.GetSize().GetX() );
|
||||
auto new_size = event.GetSize().GetX();
|
||||
|
||||
event.Skip();
|
||||
if( m_width != new_size )
|
||||
{
|
||||
AdjustGridColumns( new_size );
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -691,4 +697,4 @@ void DIALOG_EDIT_COMPONENT_IN_SCHEMATIC::OnInitDlg( wxInitDialogEvent& event )
|
|||
|
||||
// Now all widgets have the size fixed, call FinishDialogSettings
|
||||
FinishDialogSettings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,7 @@ private:
|
|||
SCH_COMPONENT* m_cmp;
|
||||
LIB_PART* m_part;
|
||||
|
||||
int m_width;
|
||||
int m_delayedFocusRow;
|
||||
int m_delayedFocusColumn;
|
||||
wxString m_shownColumns;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
||||
* Copyright (C) 1992-2019 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
|
||||
|
@ -442,6 +442,7 @@ DIALOG_LIB_EDIT_PIN_TABLE::DIALOG_LIB_EDIT_PIN_TABLE( wxWindow* parent, LIB_PART
|
|||
m_ButtonsOK->SetDefault();
|
||||
m_initialized = true;
|
||||
m_modified = false;
|
||||
m_width = 0;
|
||||
|
||||
// Connect Events
|
||||
m_grid->Connect( wxEVT_GRID_COL_SORT, wxGridEventHandler( DIALOG_LIB_EDIT_PIN_TABLE::OnColSort ), nullptr, this );
|
||||
|
@ -583,6 +584,8 @@ void DIALOG_LIB_EDIT_PIN_TABLE::OnRebuildRows( wxCommandEvent& )
|
|||
|
||||
void DIALOG_LIB_EDIT_PIN_TABLE::adjustGridColumns( int aWidth )
|
||||
{
|
||||
m_width = aWidth;
|
||||
|
||||
// Account for scroll bars
|
||||
aWidth -= ( m_grid->GetSize().x - m_grid->GetClientSize().x );
|
||||
|
||||
|
@ -617,10 +620,13 @@ void DIALOG_LIB_EDIT_PIN_TABLE::adjustGridColumns( int aWidth )
|
|||
|
||||
void DIALOG_LIB_EDIT_PIN_TABLE::OnSize( wxSizeEvent& event )
|
||||
{
|
||||
if( m_initialized )
|
||||
adjustGridColumns( event.GetSize().GetX() );
|
||||
auto new_size = event.GetSize().GetX();
|
||||
|
||||
event.Skip();
|
||||
if( m_initialized && m_width != new_size )
|
||||
{
|
||||
adjustGridColumns( new_size );
|
||||
event.Skip();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,26 @@
|
|||
/*
|
||||
* This program source code file is part of KiCad, a free EDA CAD application.
|
||||
*
|
||||
* Copyright (C) 2019 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 Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, you may find one here:
|
||||
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
||||
* or you may search the http://www.gnu.org website for the version 2 license,
|
||||
* or you may write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
||||
*/
|
||||
|
||||
#include "dialog_lib_edit_pin_table_base.h"
|
||||
|
||||
#include "class_library.h"
|
||||
|
@ -54,5 +77,7 @@ protected:
|
|||
LIB_PINS m_pins; // a copy of the pins owned by me
|
||||
bool m_modified; ///< true when there are unsaved changes
|
||||
|
||||
int m_width;
|
||||
|
||||
PIN_TABLE_DATA_MODEL* m_dataModel;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue