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() };