Fix reference text smart selection for Windows and Linux.

Fixes: lp:1782382
* https://bugs.launchpad.net/kicad/+bug/1782382
This commit is contained in:
Jeff Young 2018-07-19 20:20:53 +01:00
parent eaf5b913b6
commit 3a67300001
5 changed files with 18 additions and 4 deletions

View File

@ -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 );

View File

@ -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;

View File

@ -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 );
}

View File

@ -285,7 +285,7 @@
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSetFocus">OnSetFocusText</event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>

View File

@ -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(); }