Make HTML message box close on escape key.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/6110
This commit is contained in:
Wayne Stambaugh 2020-10-24 15:58:13 -04:00
parent 1f21a93b39
commit 16b0689841
3 changed files with 17 additions and 1 deletions

View File

@ -127,3 +127,16 @@ void HTML_MESSAGE_BOX::ShowModeless()
Show( true ); Show( true );
} }
void HTML_MESSAGE_BOX::OnCharHook( wxKeyEvent& aEvent )
{
// shift-return (Mac default) or Ctrl-Return (GTK) for OK
if( aEvent.GetKeyCode() == WXK_ESCAPE )
{
wxPostEvent( this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
return;
}
aEvent.Skip();
}

View File

@ -94,7 +94,8 @@ class DIALOG_SHIM : public wxDialog, public KIWAY_HOLDER
*/ */
void OnButton( wxCommandEvent& aEvent ); void OnButton( wxCommandEvent& aEvent );
void OnCharHook( wxKeyEvent& aEvt ); protected:
virtual void OnCharHook( wxKeyEvent& aEvt );
public: public:

View File

@ -38,6 +38,8 @@ protected:
// Handlers for HTML_MESSAGE_BOX_BASE events. // Handlers for HTML_MESSAGE_BOX_BASE events.
void OnOKButtonClick( wxCommandEvent& event ) override; void OnOKButtonClick( wxCommandEvent& event ) override;
virtual void OnCharHook( wxKeyEvent& aEvt ) override;
public: public:
HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle = wxEmptyString, HTML_MESSAGE_BOX( wxWindow* aParent, const wxString& aTitle = wxEmptyString,
const wxPoint& aPosition = wxDefaultPosition, const wxPoint& aPosition = wxDefaultPosition,