From 3a673000010fbad7cd77603751cd1b4959484ed3 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Thu, 19 Jul 2018 20:20:53 +0100 Subject: [PATCH] Fix reference text smart selection for Windows and Linux. Fixes: lp:1782382 * https://bugs.launchpad.net/kicad/+bug/1782382 --- eeschema/dialogs/dialog_edit_one_field.cpp | 10 +++++++--- eeschema/dialogs/dialog_edit_one_field.h | 7 +++++++ eeschema/dialogs/dialog_lib_edit_text_base.cpp | 2 ++ eeschema/dialogs/dialog_lib_edit_text_base.fbp | 2 +- eeschema/dialogs/dialog_lib_edit_text_base.h | 1 + 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/eeschema/dialogs/dialog_edit_one_field.cpp b/eeschema/dialogs/dialog_edit_one_field.cpp index c918f3a676..8650bb17f1 100644 --- a/eeschema/dialogs/dialog_edit_one_field.cpp +++ b/eeschema/dialogs/dialog_edit_one_field.cpp @@ -151,10 +151,8 @@ void DIALOG_EDIT_ONE_FIELD::OnTextValueSelectButtonClick( wxCommandEvent& aEvent } -bool DIALOG_EDIT_ONE_FIELD::TransferDataToWindow() +void DIALOG_EDIT_ONE_FIELD::OnSetFocusText( wxFocusEvent& event ) { - m_TextValue->SetValue( m_text ); - if( m_fieldId == REFERENCE ) { if( m_text.find_first_of( '?' ) != m_text.npos ) @@ -183,6 +181,12 @@ bool DIALOG_EDIT_ONE_FIELD::TransferDataToWindow() { m_TextValue->SetSelection( -1, -1 ); } +} + + +bool DIALOG_EDIT_ONE_FIELD::TransferDataToWindow() +{ + m_TextValue->SetValue( m_text ); m_posX.SetValue( m_position.x ); m_posY.SetValue( m_position.y ); diff --git a/eeschema/dialogs/dialog_edit_one_field.h b/eeschema/dialogs/dialog_edit_one_field.h index 590accaf1e..fedf863225 100644 --- a/eeschema/dialogs/dialog_edit_one_field.h +++ b/eeschema/dialogs/dialog_edit_one_field.h @@ -77,6 +77,13 @@ protected: */ void OnTextValueSelectButtonClick( wxCommandEvent& aEvent ) override; + /** + * Used to select the variant part of some text fields (for instance, the question mark + * or number in a reference). + * @param event + */ + virtual void OnSetFocusText( wxFocusEvent& event ) override; + UNIT_BINDER m_posX; UNIT_BINDER m_posY; UNIT_BINDER m_textSize; diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.cpp b/eeschema/dialogs/dialog_lib_edit_text_base.cpp index f0dbeddb82..f62a45396e 100644 --- a/eeschema/dialogs/dialog_lib_edit_text_base.cpp +++ b/eeschema/dialogs/dialog_lib_edit_text_base.cpp @@ -190,6 +190,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::DIALOG_LIB_EDIT_TEXT_BASE( wxWindow* parent, wxWindow // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) ); + m_TextValue->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this ); m_TextValueSelectButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this ); } @@ -197,6 +198,7 @@ DIALOG_LIB_EDIT_TEXT_BASE::~DIALOG_LIB_EDIT_TEXT_BASE() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnCloseDialog ) ); + m_TextValue->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnSetFocusText ), NULL, this ); m_TextValueSelectButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_LIB_EDIT_TEXT_BASE::OnTextValueSelectButtonClick ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.fbp b/eeschema/dialogs/dialog_lib_edit_text_base.fbp index 49d0974d51..1174c1c0d9 100644 --- a/eeschema/dialogs/dialog_lib_edit_text_base.fbp +++ b/eeschema/dialogs/dialog_lib_edit_text_base.fbp @@ -285,7 +285,7 @@ - + OnSetFocusText diff --git a/eeschema/dialogs/dialog_lib_edit_text_base.h b/eeschema/dialogs/dialog_lib_edit_text_base.h index 592a3f805e..f5e6767fb1 100644 --- a/eeschema/dialogs/dialog_lib_edit_text_base.h +++ b/eeschema/dialogs/dialog_lib_edit_text_base.h @@ -67,6 +67,7 @@ class DIALOG_LIB_EDIT_TEXT_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnCloseDialog( wxCloseEvent& event ) { event.Skip(); } + virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); } virtual void OnTextValueSelectButtonClick( wxCommandEvent& event ) { event.Skip(); }