Fixed suppress scrolling for preset comboboxes and some comboboxes on right panel on all platforms

This commit is contained in:
YuSanka 2020-11-27 22:41:23 +01:00 committed by Oleksandra Yushchenko
parent d8272d92d6
commit b71c001845
3 changed files with 17 additions and 53 deletions

View file

@ -861,27 +861,16 @@ void Choice::BUILD() {
temp->SetItemBitmap(0, empty_bmp);
#endif
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; });
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this, temp](wxCommandEvent&) {
// EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
// so, always set m_suppress_change to "true"
#ifndef __WXMSW__
if (m_last_selected == temp->GetSelection())
#endif //__WXMSW__
m_is_dropped = false;
});
temp->Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
if (m_suppress_scroll && !m_is_dropped)
e.StopPropagation();
else
e.Skip();
});
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; });
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_is_dropped = false; });
temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent evt) {
if (m_suppress_scroll) {
if (!m_is_dropped) {
temp->SetSelection(m_last_selected);
return;
}
m_last_selected = evt.GetSelection();
}
on_change_field();
m_is_dropped = false;
}), temp->GetId());
temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent) { on_change_field(); }), temp->GetId());
if (m_is_editable) {
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
@ -908,8 +897,6 @@ void Choice::BUILD() {
void Choice::suppress_scroll()
{
m_suppress_scroll = true;
choice_ctrl* ctrl = dynamic_cast<choice_ctrl*>(window);
m_last_selected = ctrl->GetSelection();
}
void Choice::set_selection()
@ -926,7 +913,6 @@ void Choice::set_selection()
case coEnum:{
int id_value = m_opt.get_default_value<ConfigOptionEnum<SeamPosition>>()->value; //!!
field->SetSelection(id_value);
if (m_suppress_scroll) m_last_selected = id_value;
break;
}
case coFloat:
@ -960,8 +946,6 @@ void Choice::set_selection()
++idx;
}
idx == m_opt.enum_values.size() ? field->SetValue(text_value) : field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
}
}
@ -981,7 +965,6 @@ void Choice::set_value(const std::string& value, bool change_event) //! Redunda
idx == m_opt.enum_values.size() ?
field->SetValue(value) :
field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
m_disable_change_event = false;
}
@ -1020,7 +1003,6 @@ void Choice::set_value(const boost::any& value, bool change_event)
}
else
field->SetSelection(idx);
if (m_suppress_scroll && idx < enums.size()) m_last_selected = idx;
break;
}
case coEnum: {
@ -1051,7 +1033,6 @@ void Choice::set_value(const boost::any& value, bool change_event)
val = 0;
}
field->SetSelection(val);
if (m_suppress_scroll) m_last_selected = val;
break;
}
default:
@ -1211,7 +1192,6 @@ void Choice::msw_rescale()
idx == m_opt.enum_values.size() ?
field->SetValue(selection) :
field->SetSelection(idx);
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
#else
auto size = wxSize(def_width_wider() * m_em_unit, wxDefaultCoord);
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);