Don't select all of textfield on each focus.

GTK (at least) generates focus events when the app is reactivated so
the text keeps getting re-selected.

Fixes https://gitlab.com/kicad/code/kicad/issues/6757
This commit is contained in:
Jeff Young 2021-01-09 19:26:07 +00:00
parent 53691585f2
commit 753442c60a
2 changed files with 20 additions and 12 deletions

View File

@ -46,6 +46,7 @@ DIALOG_EDIT_ONE_FIELD::DIALOG_EDIT_ONE_FIELD( SCH_BASE_FRAME* aParent, const wxS
m_posX( aParent, m_xPosLabel, m_xPosCtrl, m_xPosUnits, true ),
m_posY( aParent, m_yPosLabel, m_yPosCtrl, m_yPosUnits, true ),
m_textSize( aParent, m_textSizeLabel, m_textSizeCtrl, m_textSizeUnits, true ),
m_firstFocus( true ),
m_scintillaTricks( nullptr )
{
wxASSERT( aTextItem );
@ -165,6 +166,8 @@ void DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick( wxCommandEvent& aEvent
void DIALOG_EDIT_ONE_FIELD::OnSetFocusText( wxFocusEvent& event )
{
if( m_firstFocus )
{
#ifdef __WXGTK__
// Force an update of the text control before setting the text selection
@ -182,6 +185,9 @@ void DIALOG_EDIT_ONE_FIELD::OnSetFocusText( wxFocusEvent& event )
else if( m_fieldId == VALUE_FIELD || m_fieldId == SHEETNAME_V )
m_TextCtrl->SetSelection( -1, -1 );
m_firstFocus = false;
}
event.Skip();
}

View File

@ -102,6 +102,8 @@ protected:
int m_horizontalJustification;
bool m_isVisible;
bool m_firstFocus;
SCINTILLA_TRICKS* m_scintillaTricks;
};