This commit is contained in:
Enrico Turri 2018-12-21 11:13:47 +01:00
commit 4c823fea40
2 changed files with 9 additions and 6 deletions

View File

@ -400,10 +400,11 @@ void SpinCtrl::BUILD() {
auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size, auto temp = new wxSpinCtrl(m_parent, wxID_ANY, text_value, wxDefaultPosition, size,
0, min_val, max_val, default_value); 0, min_val, max_val, default_value);
// temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { tmp_value = undef_spin_val; on_change_field(); }), temp->GetId()); #ifndef __WXOSX__
// #ys_FIXME_KILL_FOCUS // #ys_FIXME_KILL_FOCUS
// wxEVT_KILL_FOCUS doesn't handled on OSX now // wxEVT_KILL_FOCUS doesn't handled on OSX now (wxWidgets 3.1.1)
// So, we will update values on KILL_FOCUS & SPINCTRL events under MSW and GTK
// and on TEXT event under OSX
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e)
{ {
if (tmp_value < 0) if (tmp_value < 0)
@ -414,6 +415,9 @@ void SpinCtrl::BUILD() {
} }
}), temp->GetId()); }), temp->GetId());
temp->Bind(wxEVT_SPINCTRL, ([this](wxCommandEvent e) { on_change_field(); }), temp->GetId());
#endif
temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e) temp->Bind(wxEVT_TEXT, ([this](wxCommandEvent e)
{ {
// # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value // # On OSX / Cocoa, wxSpinCtrl::GetValue() doesn't return the new value
@ -425,9 +429,7 @@ void SpinCtrl::BUILD() {
if (is_matched(value, "^\\d+$")) if (is_matched(value, "^\\d+$"))
tmp_value = std::stoi(value); tmp_value = std::stoi(value);
else tmp_value = -9999; else tmp_value = -9999;
// on_change_field();
#ifdef __WXOSX__ #ifdef __WXOSX__
// #ys_FIXME_KILL_FOCUS so call on_change_field() inside wxEVT_TEXT
if (tmp_value < 0) { if (tmp_value < 0) {
if (m_on_kill_focus != nullptr) if (m_on_kill_focus != nullptr)
m_on_kill_focus(m_opt_id); m_on_kill_focus(m_opt_id);

View File

@ -224,7 +224,8 @@ PresetComboBox::PresetComboBox(wxWindow *parent, Preset::Type preset_type) :
if (marker == LABEL_ITEM_MARKER) { if (marker == LABEL_ITEM_MARKER) {
this->SetSelection(this->last_selected); this->SetSelection(this->last_selected);
evt.StopPropagation(); evt.StopPropagation();
} else if (this->last_selected != selected_item) { } else if ( this->last_selected != selected_item ||
wxGetApp().get_tab(this->preset_type)->get_presets()->current_is_dirty() ) {
this->last_selected = selected_item; this->last_selected = selected_item;
evt.SetInt(this->preset_type); evt.SetInt(this->preset_type);
evt.Skip(); evt.Skip();