Make OK default in inspectors (and hook up to close window).

Fixes https://gitlab.com/kicad/code/kicad/issues/7831
This commit is contained in:
Jeff Young 2021-03-22 20:06:05 +00:00
parent a677998f47
commit f24f0d93a5
9 changed files with 34 additions and 4 deletions

View File

@ -11,7 +11,7 @@
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style )
{ {
this->SetSizeHints( wxDefaultSize, wxDefaultSize ); this->SetSizeHints( wxDefaultSize, wxDefaultSize );
@ -39,11 +39,13 @@ DIALOG_HTML_REPORTER::DIALOG_HTML_REPORTER( wxWindow* parent, wxWindowID id, con
// Connect Events // Connect Events
m_Reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this ); m_Reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_HTML_REPORTER::OnOK ), NULL, this );
} }
DIALOG_HTML_REPORTER::~DIALOG_HTML_REPORTER() DIALOG_HTML_REPORTER::~DIALOG_HTML_REPORTER()
{ {
// Disconnect Events // Disconnect Events
m_Reporter->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this ); m_Reporter->Disconnect( wxEVT_COMMAND_HTML_LINK_CLICKED, wxHtmlLinkEventHandler( DIALOG_HTML_REPORTER::OnErrorLinkClicked ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_HTML_REPORTER::OnOK ), NULL, this );
} }

View File

@ -47,7 +47,7 @@
<property name="pos"></property> <property name="pos"></property>
<property name="size"></property> <property name="size"></property>
<property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property> <property name="style">wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER</property>
<property name="subclass">; ; forward_declare</property> <property name="subclass">DIALOG_SHIM; dialog_shim.h; forward_declare</property>
<property name="title">Report</property> <property name="title">Report</property>
<property name="tooltip"></property> <property name="tooltip"></property>
<property name="window_extra_style"></property> <property name="window_extra_style"></property>
@ -133,6 +133,7 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">m_sdbSizer</property> <property name="name">m_sdbSizer</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<event name="OnOKButtonClick">OnOK</event>
</object> </object>
</object> </object>
</object> </object>

View File

@ -12,6 +12,7 @@
#include <wx/intl.h> #include <wx/intl.h>
class WX_HTML_REPORT_BOX; class WX_HTML_REPORT_BOX;
#include "dialog_shim.h"
#include <wx/html/htmlwin.h> #include <wx/html/htmlwin.h>
#include <wx/gdicmn.h> #include <wx/gdicmn.h>
#include <wx/font.h> #include <wx/font.h>
@ -28,7 +29,7 @@ class WX_HTML_REPORT_BOX;
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_HTML_REPORTER /// Class DIALOG_HTML_REPORTER
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
class DIALOG_HTML_REPORTER : public wxDialog class DIALOG_HTML_REPORTER : public DIALOG_SHIM
{ {
private: private:
@ -38,6 +39,7 @@ class DIALOG_HTML_REPORTER : public wxDialog
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void OnErrorLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); } virtual void OnErrorLinkClicked( wxHtmlLinkEvent& event ) { event.Skip(); }
virtual void OnOK( wxCommandEvent& event ) { event.Skip(); }
public: public:

View File

@ -36,6 +36,7 @@ DIALOG_CONSTRAINTS_REPORTER::DIALOG_CONSTRAINTS_REPORTER( PCB_EDIT_FRAME* aParen
void DIALOG_CONSTRAINTS_REPORTER::FinishInitialization() void DIALOG_CONSTRAINTS_REPORTER::FinishInitialization()
{ {
m_sdbSizerOK->SetDefault();
finishDialogSettings(); finishDialogSettings();
} }

View File

@ -37,6 +37,11 @@ public:
void FinishInitialization(); void FinishInitialization();
void OnOK( wxCommandEvent& event ) override
{
Close();
}
void OnErrorLinkClicked( wxHtmlLinkEvent& event ); void OnErrorLinkClicked( wxHtmlLinkEvent& event );
void DeleteAllPages(); void DeleteAllPages();

View File

@ -35,8 +35,14 @@ DIALOG_CONSTRAINTS_REPORTER_BASE::DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* pa
bMainSizer->Fit( this ); bMainSizer->Fit( this );
this->Centre( wxBOTH ); this->Centre( wxBOTH );
// Connect Events
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONSTRAINTS_REPORTER_BASE::OnOK ), NULL, this );
} }
DIALOG_CONSTRAINTS_REPORTER_BASE::~DIALOG_CONSTRAINTS_REPORTER_BASE() DIALOG_CONSTRAINTS_REPORTER_BASE::~DIALOG_CONSTRAINTS_REPORTER_BASE()
{ {
// Disconnect Events
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_CONSTRAINTS_REPORTER_BASE::OnOK ), NULL, this );
} }

View File

@ -133,6 +133,7 @@
<property name="minimum_size"></property> <property name="minimum_size"></property>
<property name="name">m_sdbSizer</property> <property name="name">m_sdbSizer</property>
<property name="permission">protected</property> <property name="permission">protected</property>
<event name="OnOKButtonClick">OnOK</event>
</object> </object>
</object> </object>
</object> </object>

View File

@ -36,6 +36,10 @@ class DIALOG_CONSTRAINTS_REPORTER_BASE : public DIALOG_SHIM
wxStdDialogButtonSizer* m_sdbSizer; wxStdDialogButtonSizer* m_sdbSizer;
wxButton* m_sdbSizerOK; wxButton* m_sdbSizerOK;
// Virtual event handlers, overide them in your derived class
virtual void OnOK( wxCommandEvent& event ) { event.Skip(); }
public: public:
DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Constraints Resolution Report"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER ); DIALOG_CONSTRAINTS_REPORTER_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Constraints Resolution Report"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER );

View File

@ -41,10 +41,18 @@ public:
DIALOG_INSPECTION_REPORTER( PCB_EDIT_FRAME* aFrame ) : DIALOG_INSPECTION_REPORTER( PCB_EDIT_FRAME* aFrame ) :
DIALOG_HTML_REPORTER( aFrame ), DIALOG_HTML_REPORTER( aFrame ),
m_frame( aFrame ) m_frame( aFrame )
{ } {
m_sdbSizerOK->SetDefault();
SetInitialFocus( m_sdbSizerOK );
}
void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override; void OnErrorLinkClicked( wxHtmlLinkEvent& event ) override;
void OnOK( wxCommandEvent& event ) override
{
Close();
}
protected: protected:
PCB_EDIT_FRAME* m_frame; PCB_EDIT_FRAME* m_frame;
}; };