Handle single- and double-click in Place Footprint history list.
Old code failed to set the wxEventType during acceptance, and failed to set the default button during initialization. Fixes: lp:1768253 * https://bugs.launchpad.net/kicad/+bug/1768253
This commit is contained in:
parent
8f2fee8bb8
commit
aec490e3ac
|
@ -60,12 +60,20 @@ DIALOG_GET_FOOTPRINT::DIALOG_GET_FOOTPRINT( PCB_BASE_FRAME* parent, bool aShowBr
|
|||
m_buttonBrowse->Show( aShowBrowseButton );
|
||||
m_buttonBrowse->Enable( aShowBrowseButton );
|
||||
|
||||
m_sdbSizerOK->SetDefault();
|
||||
|
||||
m_textCmpNameCtrl->SetFocus();
|
||||
GetSizer()->Fit( this );
|
||||
GetSizer()->SetSizeHints( this );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GET_FOOTPRINT::OnHistoryClick( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_textCmpNameCtrl->SetValue( m_historyList->GetStringSelection() );
|
||||
}
|
||||
|
||||
|
||||
void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
|
||||
{
|
||||
m_selectionIsKeyword = false;
|
||||
|
@ -76,7 +84,10 @@ void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
|
|||
break;
|
||||
|
||||
case wxID_OK:
|
||||
m_Text = m_textCmpNameCtrl->GetValue();
|
||||
if( m_historyList->HasFocus() )
|
||||
m_Text = m_historyList->GetStringSelection();
|
||||
else
|
||||
m_Text = m_textCmpNameCtrl->GetValue();
|
||||
break;
|
||||
|
||||
case ID_ACCEPT_KEYWORD:
|
||||
|
@ -98,6 +109,7 @@ void DIALOG_GET_FOOTPRINT::Accept( wxCommandEvent& aEvent )
|
|||
m_Text.Trim( true ); // Remove blanks at end
|
||||
|
||||
// Put an wxID_OK event through the dialog infrastrucutre
|
||||
aEvent.SetEventType( wxEVT_COMMAND_BUTTON_CLICKED );
|
||||
aEvent.SetId( wxID_OK );
|
||||
aEvent.Skip();
|
||||
}
|
||||
|
|
|
@ -74,6 +74,7 @@ public:
|
|||
void SetComponentName( const wxString& name );
|
||||
|
||||
private:
|
||||
void OnHistoryClick( wxCommandEvent& aEvent ) override;
|
||||
void Accept( wxCommandEvent& aEvent ) override;
|
||||
};
|
||||
|
||||
|
|
|
@ -79,7 +79,8 @@ DIALOG_GET_FOOTPRINT_BASE::DIALOG_GET_FOOTPRINT_BASE( wxWindow* parent, wxWindow
|
|||
this->Centre( wxBOTH );
|
||||
|
||||
// Connect Events
|
||||
m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_historyList->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::OnHistoryClick ), NULL, this );
|
||||
m_historyList->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonKW->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonList->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
|
@ -89,7 +90,8 @@ DIALOG_GET_FOOTPRINT_BASE::DIALOG_GET_FOOTPRINT_BASE( wxWindow* parent, wxWindow
|
|||
DIALOG_GET_FOOTPRINT_BASE::~DIALOG_GET_FOOTPRINT_BASE()
|
||||
{
|
||||
// Disconnect Events
|
||||
m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::OnHistoryClick ), NULL, this );
|
||||
m_historyList->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonKW->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonList->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GET_FOOTPRINT_BASE::Accept ), NULL, this );
|
||||
|
|
|
@ -439,8 +439,8 @@
|
|||
<event name="OnLeftDClick"></event>
|
||||
<event name="OnLeftDown"></event>
|
||||
<event name="OnLeftUp"></event>
|
||||
<event name="OnListBox">Accept</event>
|
||||
<event name="OnListBoxDClick"></event>
|
||||
<event name="OnListBox">OnHistoryClick</event>
|
||||
<event name="OnListBoxDClick">Accept</event>
|
||||
<event name="OnMiddleDClick"></event>
|
||||
<event name="OnMiddleDown"></event>
|
||||
<event name="OnMiddleUp"></event>
|
||||
|
|
|
@ -53,6 +53,7 @@ class DIALOG_GET_FOOTPRINT_BASE : public DIALOG_SHIM
|
|||
wxButton* m_sdbSizerCancel;
|
||||
|
||||
// Virtual event handlers, overide them in your derived class
|
||||
virtual void OnHistoryClick( wxCommandEvent& event ) { event.Skip(); }
|
||||
virtual void Accept( wxCommandEvent& event ) { event.Skip(); }
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue