Fixed suppress scrolling for preset comboboxes and some comboboxes on right panel on all platforms
This commit is contained in:
parent
d8272d92d6
commit
b71c001845
3 changed files with 17 additions and 53 deletions
|
@ -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);
|
||||
|
|
|
@ -103,15 +103,15 @@ PresetComboBox::PresetComboBox(wxWindow* parent, Preset::Type preset_type, const
|
|||
|
||||
// parameters for an icon's drawing
|
||||
fill_width_height();
|
||||
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_suppress_change = false; });
|
||||
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](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 == this->GetSelection())
|
||||
#endif //__WXMSW__
|
||||
m_suppress_change = true;
|
||||
|
||||
Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
|
||||
if (m_suppress_change)
|
||||
e.StopPropagation();
|
||||
else
|
||||
e.Skip();
|
||||
});
|
||||
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_suppress_change = false; });
|
||||
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) { m_suppress_change = true; });
|
||||
|
||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
||||
|
@ -156,15 +156,6 @@ bool PresetComboBox::set_printer_technology(PrinterTechnology pt)
|
|||
return false;
|
||||
}
|
||||
|
||||
bool PresetComboBox::check_event_for_suppress_change(wxCommandEvent& evt)
|
||||
{
|
||||
if (m_suppress_change) {
|
||||
evt.StopPropagation();
|
||||
SetSelection(m_last_selected);
|
||||
}
|
||||
return m_suppress_change;
|
||||
}
|
||||
|
||||
void PresetComboBox::invalidate_selection()
|
||||
{
|
||||
m_last_selected = INT_MAX; // this value means that no one item is selected
|
||||
|
@ -552,8 +543,6 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
|
|||
PresetComboBox(parent, preset_type, wxSize(15 * wxGetApp().em_unit(), -1))
|
||||
{
|
||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
||||
if (check_event_for_suppress_change(evt))
|
||||
return;
|
||||
auto selected_item = evt.GetSelection();
|
||||
|
||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||
|
@ -579,7 +568,6 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
|
|||
} else {
|
||||
evt.StopPropagation();
|
||||
}
|
||||
m_suppress_change = true;
|
||||
});
|
||||
|
||||
if (m_type == Preset::TYPE_FILAMENT)
|
||||
|
@ -892,8 +880,6 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type)
|
|||
PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1))
|
||||
{
|
||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
||||
if (check_event_for_suppress_change(evt))
|
||||
return;
|
||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
||||
// Under OSX: in case of use of a same names written in different case (like "ENDER" and "Ender")
|
||||
// m_presets_choice->GetSelection() will return first item, because search in PopupListCtrl is case-insensitive.
|
||||
|
@ -919,7 +905,6 @@ TabPresetComboBox::TabPresetComboBox(wxWindow* parent, Preset::Type preset_type)
|
|||
}
|
||||
|
||||
evt.StopPropagation();
|
||||
m_suppress_change = true;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,6 @@ protected:
|
|||
|
||||
PrinterTechnology printer_technology {ptAny};
|
||||
|
||||
bool check_event_for_suppress_change(wxCommandEvent& evt);
|
||||
void invalidate_selection();
|
||||
void validate_selection(bool predicate = false);
|
||||
void update_selection();
|
||||
|
|
Loading…
Reference in a new issue