diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:09:24 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:09:24 +0200 |
commit | b5f042a6c132c1b97cf03c4615bab966c23f57d2 (patch) | |
tree | 1cb057a0ffd51264bb3c9807e2133505ce312eb1 /shared/custom_combo_box.cpp | |
parent | 3.11 (diff) | |
download | FreeFileSync-b5f042a6c132c1b97cf03c4615bab966c23f57d2.tar.gz FreeFileSync-b5f042a6c132c1b97cf03c4615bab966c23f57d2.tar.bz2 FreeFileSync-b5f042a6c132c1b97cf03c4615bab966c23f57d2.zip |
3.12
Diffstat (limited to 'shared/custom_combo_box.cpp')
-rw-r--r-- | shared/custom_combo_box.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/shared/custom_combo_box.cpp b/shared/custom_combo_box.cpp index 3c2a118c..18adb38a 100644 --- a/shared/custom_combo_box.cpp +++ b/shared/custom_combo_box.cpp @@ -18,12 +18,36 @@ CustomComboBox::CustomComboBox(wxWindow* parent, const wxValidator& validator, const wxString& name) : wxComboBox(parent, id, value, pos, size, n, choices, style, validator, name) +#if wxCHECK_VERSION(2, 9, 1) + , dropDownShown(false) +#endif { //register key event to enable item deletion this->Connect(wxEVT_KEY_DOWN, wxKeyEventHandler(CustomComboBox::OnKeyEvent), NULL, this ); + +#if wxCHECK_VERSION(2, 9, 1) + this->Connect(wxEVT_COMMAND_COMBOBOX_DROPDOWN, wxCommandEventHandler(CustomComboBox::OnShowDropDown), NULL, this ); + this->Connect(wxEVT_COMMAND_COMBOBOX_CLOSEUP, wxCommandEventHandler(CustomComboBox::OnHideDropDown), NULL, this ); +#endif +} + + +#if wxCHECK_VERSION(2, 9, 1) +void CustomComboBox::OnShowDropDown(wxCommandEvent& event) +{ + dropDownShown = true; + event.Skip(); } +void CustomComboBox::OnHideDropDown(wxCommandEvent& event) +{ + dropDownShown = false; + event.Skip(); +} +#endif + + void CustomComboBox::OnKeyEvent(wxKeyEvent& event) { const int keyCode = event.GetKeyCode(); @@ -32,11 +56,16 @@ void CustomComboBox::OnKeyEvent(wxKeyEvent& event) //try to delete the currently selected config history item const int selectedItem = this->GetCurrentSelection(); if (0 <= selectedItem && selectedItem < static_cast<int>(this->GetCount()) && - (GetValue() != GetString(selectedItem) || //avoid problems when a character shall be deleted instead of list item - GetValue() == wxEmptyString)) //exception: always allow removing empty entry - { - //save old (selected) value: deletion seems to have influence on this - const wxString currentVal = this->GetValue(); +#if wxCHECK_VERSION(2, 9, 1) + dropDownShown) +#else + //what a mess...: + (GetValue() != GetString(selectedItem) || //avoid problems when a character shall be deleted instead of list item + GetValue() == wxEmptyString)) //exception: always allow removing empty entry +#endif + { + //save old (selected) value: deletion seems to have influence on this + const wxString currentVal = this->GetValue(); this->SetSelection(wxNOT_FOUND); //delete selected row |