From 336745cdb29f9f3bead1507670651580b896d7df Mon Sep 17 00:00:00 2001 From: wangqr Date: Sun, 15 Sep 2019 19:32:49 -0400 Subject: [PATCH] In Properties dialog, create the button first So the foucus goes to the OK button on init. This will let wxWidgets correctly handle the initial position of text in wxTextCtrl Fix wangqr/Aegisub#6 --- src/dialog_properties.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/dialog_properties.cpp b/src/dialog_properties.cpp index d19c70ae5..76d7477cd 100644 --- a/src/dialog_properties.cpp +++ b/src/dialog_properties.cpp @@ -91,6 +91,14 @@ DialogProperties::DialogProperties(agi::Context *c) { d.SetIcon(GETICON(properties_toolbutton_16)); + // Button sizer + // Create buttons first. See: + // https://github.com/wangqr/Aegisub/issues/6 + // https://trac.wxwidgets.org/ticket/18472#comment:9 + auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); + d.Bind(wxEVT_BUTTON, &DialogProperties::OnOK, this, wxID_OK); + d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Properties"), wxID_HELP); + // Script details crap wxSizer *TopSizer = new wxStaticBoxSizer(wxHORIZONTAL,&d,_("Script")); auto TopSizerGrid = new wxFlexGridSizer(0,2,5,5); @@ -156,11 +164,6 @@ DialogProperties::DialogProperties(agi::Context *c) optionsGrid->AddGrowableCol(1,1); optionsBox->Add(optionsGrid,1,wxEXPAND,0); - // Button sizer - auto ButtonSizer = d.CreateStdDialogButtonSizer(wxOK | wxCANCEL | wxHELP); - d.Bind(wxEVT_BUTTON, &DialogProperties::OnOK, this, wxID_OK); - d.Bind(wxEVT_BUTTON, std::bind(&HelpButton::OpenPage, "Properties"), wxID_HELP); - // MainSizer wxSizer *MainSizer = new wxBoxSizer(wxVERTICAL); MainSizer->Add(TopSizer,0,wxLEFT | wxRIGHT | wxBOTTOM | wxEXPAND,5);