From 33c27c5684771c7711cd6d81d1c015ecd57f34df Mon Sep 17 00:00:00 2001 From: "Charles J. Cliffe" Date: Tue, 9 Feb 2016 00:46:39 -0500 Subject: [PATCH] Fix initial numeric input char for Windows --- src/FrequencyDialog.cpp | 11 ++++++++++- src/FrequencyDialog.h | 2 ++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/FrequencyDialog.cpp b/src/FrequencyDialog.cpp index d36918b..d44274c 100644 --- a/src/FrequencyDialog.cpp +++ b/src/FrequencyDialog.cpp @@ -6,6 +6,7 @@ wxBEGIN_EVENT_TABLE(FrequencyDialog, wxDialog) EVT_CHAR_HOOK(FrequencyDialog::OnChar) +EVT_SHOW(FrequencyDialog::OnShow) wxEND_EVENT_TABLE() FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxString & title, DemodulatorInstance *demod, const wxPoint & position, @@ -14,6 +15,7 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin wxString freqStr; activeDemod = demod; this->targetMode = targetMode; + this->initialString = initString; if (targetMode == FDIALOG_TARGET_DEFAULT) { if (activeDemod) { @@ -54,7 +56,7 @@ FrequencyDialog::FrequencyDialog(wxWindow * parent, wxWindowID id, const wxStrin if (initString != "" && initString.length() == 1) { dialogText->SetValue(initString); - dialogText->SetSelection(initString.length(), initString.length()); + dialogText->SetSelection(2, 2); dialogText->SetFocus(); } else { if (initString != "") { @@ -183,3 +185,10 @@ void FrequencyDialog::OnChar(wxKeyEvent& event) { event.Skip(); } } + +void FrequencyDialog::OnShow(wxShowEvent &event) { + if (initialString.length() == 1) { + dialogText->SetSelection(2, 2); + dialogText->SetFocus(); + } +} \ No newline at end of file diff --git a/src/FrequencyDialog.h b/src/FrequencyDialog.h index 681b4aa..6353c39 100644 --- a/src/FrequencyDialog.h +++ b/src/FrequencyDialog.h @@ -34,6 +34,8 @@ private: DemodulatorInstance *activeDemod; void OnEnter ( wxCommandEvent &event ); void OnChar ( wxKeyEvent &event ); + void OnShow(wxShowEvent &event); FrequencyDialogTarget targetMode; + std::string initialString; DECLARE_EVENT_TABLE() };