Remove autocomplete when we lose focus

Prevents the excess dropdown from persisting over windows

Fixes https://gitlab.com/kicad/code/kicad/issues/9651
This commit is contained in:
Seth Hillbrand 2021-11-19 17:23:43 -08:00
parent 7529eb1812
commit 766a09c338
12 changed files with 43 additions and 6 deletions

View File

@ -402,3 +402,8 @@ void SCINTILLA_TRICKS::DoAutocomplete( const wxString& aPartial, const wxArraySt
}
void SCINTILLA_TRICKS::CancelAutocomplete()
{
m_te->AutoCompCancel();
}

View File

@ -394,6 +394,13 @@ bool DIALOG_TEXT_AND_LABEL_PROPERTIES::TransferDataFromWindow()
}
void DIALOG_TEXT_AND_LABEL_PROPERTIES::onLostFocus( wxFocusEvent& event )
{
if( m_scintillaTricks )
m_scintillaTricks->CancelAutocomplete();
}
void DIALOG_TEXT_AND_LABEL_PROPERTIES::OnFormattingHelp( wxHyperlinkEvent& aEvent )
{
m_helpWindow = SCH_TEXT::ShowSyntaxHelp( this );

View File

@ -52,6 +52,7 @@ private:
void OnEnterKey( wxCommandEvent& aEvent ) override;
void OnFormattingHelp( wxHyperlinkEvent& aEvent ) override;
void onLostFocus( wxFocusEvent& event ) override;
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -48,6 +48,7 @@ DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE( wx
m_valueMultiLine->SetViewWhiteSpace( false );
m_valueMultiLine->SetMarginWidth( 2, 0 );
m_valueMultiLine->SetIndentationGuides( false );
m_valueMultiLine->SetReadOnly( false );
m_valueMultiLine->SetMarginWidth( 1, 0 );
m_valueMultiLine->SetMarginWidth( 0, 0 );
m_valueMultiLine->MarkerDefine( wxSTC_MARKNUM_FOLDER, wxSTC_MARK_BOXPLUS );
@ -160,6 +161,7 @@ DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE( wx
// Connect Events
m_valueSingleLine->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this );
m_valueMultiLine->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::onLostFocus ), NULL, this );
m_valueCombo->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this );
m_formattingHelp->Connect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this );
}
@ -168,6 +170,7 @@ DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::~DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE()
{
// Disconnect Events
m_valueSingleLine->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this );
m_valueMultiLine->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::onLostFocus ), NULL, this );
m_valueCombo->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnEnterKey ), NULL, this );
m_formattingHelp->Disconnect( wxEVT_COMMAND_HYPERLINK, wxHyperlinkEventHandler( DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE::OnFormattingHelp ), NULL, this );

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="15" />
<FileVersion major="1" minor="16" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
@ -14,6 +14,7 @@
<property name="file">dialog_text_and_label_properties_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="image_path_wrapper_function_name"></property>
<property name="indent_with_spaces"></property>
<property name="internationalize">1</property>
<property name="name">dialog_text_and_label_properties_base</property>
@ -25,6 +26,7 @@
<property name="skip_php_events">1</property>
<property name="skip_python_events">1</property>
<property name="ui_table">UI</property>
<property name="use_array_enum">0</property>
<property name="use_enum">1</property>
<property name="use_microsoft_bom">0</property>
<object class="Dialog" expanded="1">
@ -50,6 +52,7 @@
<property name="subclass">DIALOG_SHIM; dialog_shim.h</property>
<property name="title">Text Properties</property>
<property name="tooltip"></property>
<property name="two_step_creation">0</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
@ -311,6 +314,7 @@
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="read_only">0</property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
@ -325,6 +329,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxBORDER_SUNKEN</property>
<event name="OnKillFocus">onLostFocus</event>
</object>
</object>
<object class="sizeritem" expanded="1">

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Oct 26 2018)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -62,14 +62,16 @@ class DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE : public DIALOG_SHIM
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
// Virtual event handlers, override them in your derived class
virtual void OnEnterKey( wxCommandEvent& event ) { event.Skip(); }
virtual void onLostFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void OnFormattingHelp( wxHyperlinkEvent& event ) { event.Skip(); }
public:
DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Text Properties"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );
~DIALOG_TEXT_AND_LABEL_PROPERTIES_BASE();
};

View File

@ -40,6 +40,8 @@ public:
void DoAutocomplete( const wxString& aPartial, const wxArrayString& aTokens );
void CancelAutocomplete();
protected:
void setupStyles();

View File

@ -369,3 +369,10 @@ bool DIALOG_TEXT_PROPERTIES::TransferDataFromWindow()
return true;
}
void DIALOG_TEXT_PROPERTIES::onLostFocus( wxFocusEvent& event )
{
if( m_scintillaTricks )
m_scintillaTricks->CancelAutocomplete();
}

View File

@ -54,6 +54,7 @@ public:
private:
bool TransferDataToWindow() override;
bool TransferDataFromWindow() override;
void onLostFocus( wxFocusEvent& event ) override;
private:
PCB_BASE_EDIT_FRAME* m_Parent;

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -262,6 +262,7 @@ DIALOG_TEXT_PROPERTIES_BASE::DIALOG_TEXT_PROPERTIES_BASE( wxWindow* parent, wxWi
// Connect Events
this->Connect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnInitDlg ) );
m_MultiLineText->Connect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onLostFocus ), NULL, this );
m_SingleLineText->Connect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this );
m_SingleLineText->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeXCtrl->Connect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
@ -277,6 +278,7 @@ DIALOG_TEXT_PROPERTIES_BASE::~DIALOG_TEXT_PROPERTIES_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_INIT_DIALOG, wxInitDialogEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnInitDlg ) );
m_MultiLineText->Disconnect( wxEVT_KILL_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::onLostFocus ), NULL, this );
m_SingleLineText->Disconnect( wxEVT_SET_FOCUS, wxFocusEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnSetFocusText ), NULL, this );
m_SingleLineText->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );
m_SizeXCtrl->Disconnect( wxEVT_COMMAND_TEXT_ENTER, wxCommandEventHandler( DIALOG_TEXT_PROPERTIES_BASE::OnOkClick ), NULL, this );

View File

@ -197,6 +197,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnKillFocus">onLostFocus</event>
</object>
</object>
</object>

View File

@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version 3.10.0-4761b0c5)
// C++ code generated with wxFormBuilder (version 3.10.0)
// http://www.wxformbuilder.org/
//
// PLEASE DO *NOT* EDIT THIS FILE!
@ -80,6 +80,7 @@ class DIALOG_TEXT_PROPERTIES_BASE : public DIALOG_SHIM
// Virtual event handlers, override them in your derived class
virtual void OnInitDlg( wxInitDialogEvent& event ) { event.Skip(); }
virtual void onLostFocus( wxFocusEvent& event ) { event.Skip(); }
virtual void OnSetFocusText( wxFocusEvent& event ) { event.Skip(); }
virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }