From aaabe1cb1710f265e497019d52acaa7569bc76cc Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 25 Jan 2018 19:36:28 +0100 Subject: [PATCH] Improve validate sample UI a bit Provide an accelerator for the menu command which contains all of the test functionality to make it simpler to test it. Also use CreateButtonSizer() instead of creating wxStdDialogButtonSizer manually to make the code shorter and to also ensure that the "OK" button is correctly set up as the default one, allowing to press "Enter" in this dialog to accept the entry on any control, which didn't work before. --- samples/validate/validate.cpp | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/samples/validate/validate.cpp b/samples/validate/validate.cpp index b5594fcf34..36c8900440 100644 --- a/samples/validate/validate.cpp +++ b/samples/validate/validate.cpp @@ -166,7 +166,7 @@ MyFrame::MyFrame(wxFrame *frame, const wxString&title, int x, int y, int w, int wxMenu *file_menu = new wxMenu; - file_menu->Append(VALIDATE_TEST_DIALOG, wxT("&Test dialog..."), wxT("Demonstrate validators")); + file_menu->Append(VALIDATE_TEST_DIALOG, wxT("&Test dialog...\tCtrl-T"), wxT("Demonstrate validators")); file_menu->AppendCheckItem(VALIDATE_TOGGLE_BELL, wxT("&Bell on error"), wxT("Toggle bell on error")); file_menu->AppendSeparator(); file_menu->Append(wxID_EXIT, wxT("E&xit")); @@ -297,14 +297,6 @@ MyDialog::MyDialog( wxWindow *parent, const wxString& title, flexgridsizer->AddGrowableRow(1); - // setup the button sizer - // ---------------------- - - wxStdDialogButtonSizer *btn = new wxStdDialogButtonSizer(); - btn->AddButton(new wxButton(this, wxID_OK)); - btn->AddButton(new wxButton(this, wxID_CANCEL)); - btn->Realize(); - // setup a sizer with the controls for numeric validators // ------------------------------------------------------ @@ -391,7 +383,8 @@ MyDialog::MyDialog( wxWindow *parent, const wxString& title, mainsizer->Add( numSizer, wxSizerFlags().Expand().DoubleBorder() ); - mainsizer->Add(btn, 0, wxGROW | wxALL, 10); + mainsizer->Add(CreateButtonSizer(wxOK | wxCANCEL), + wxSizerFlags().Expand().DoubleBorder()); SetSizer(mainsizer); mainsizer->SetSizeHints(this);