mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-06-01 06:08:13 +08:00
Fixed suppress scrolling for preset comboboxes and some comboboxes on right panel on all platforms
This commit is contained in:
parent
d8272d92d6
commit
b71c001845
@ -861,27 +861,16 @@ void Choice::BUILD() {
|
|||||||
temp->SetItemBitmap(0, empty_bmp);
|
temp->SetItemBitmap(0, empty_bmp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
temp->Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_is_dropped = true; });
|
temp->Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
|
||||||
temp->Bind(wxEVT_COMBOBOX_CLOSEUP, [this, temp](wxCommandEvent&) {
|
if (m_suppress_scroll && !m_is_dropped)
|
||||||
// EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
|
e.StopPropagation();
|
||||||
// so, always set m_suppress_change to "true"
|
else
|
||||||
#ifndef __WXMSW__
|
e.Skip();
|
||||||
if (m_last_selected == temp->GetSelection())
|
|
||||||
#endif //__WXMSW__
|
|
||||||
m_is_dropped = false;
|
|
||||||
});
|
});
|
||||||
|
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) {
|
temp->Bind(wxEVT_COMBOBOX, ([this, temp](wxCommandEvent) { on_change_field(); }), temp->GetId());
|
||||||
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());
|
|
||||||
|
|
||||||
if (m_is_editable) {
|
if (m_is_editable) {
|
||||||
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
|
temp->Bind(wxEVT_KILL_FOCUS, ([this](wxEvent& e) {
|
||||||
@ -908,8 +897,6 @@ void Choice::BUILD() {
|
|||||||
void Choice::suppress_scroll()
|
void Choice::suppress_scroll()
|
||||||
{
|
{
|
||||||
m_suppress_scroll = true;
|
m_suppress_scroll = true;
|
||||||
choice_ctrl* ctrl = dynamic_cast<choice_ctrl*>(window);
|
|
||||||
m_last_selected = ctrl->GetSelection();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Choice::set_selection()
|
void Choice::set_selection()
|
||||||
@ -926,7 +913,6 @@ void Choice::set_selection()
|
|||||||
case coEnum:{
|
case coEnum:{
|
||||||
int id_value = m_opt.get_default_value<ConfigOptionEnum<SeamPosition>>()->value; //!!
|
int id_value = m_opt.get_default_value<ConfigOptionEnum<SeamPosition>>()->value; //!!
|
||||||
field->SetSelection(id_value);
|
field->SetSelection(id_value);
|
||||||
if (m_suppress_scroll) m_last_selected = id_value;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case coFloat:
|
case coFloat:
|
||||||
@ -960,8 +946,6 @@ void Choice::set_selection()
|
|||||||
++idx;
|
++idx;
|
||||||
}
|
}
|
||||||
idx == m_opt.enum_values.size() ? field->SetValue(text_value) : field->SetSelection(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() ?
|
idx == m_opt.enum_values.size() ?
|
||||||
field->SetValue(value) :
|
field->SetValue(value) :
|
||||||
field->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
|
|
||||||
|
|
||||||
m_disable_change_event = false;
|
m_disable_change_event = false;
|
||||||
}
|
}
|
||||||
@ -1020,7 +1003,6 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
field->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
if (m_suppress_scroll && idx < enums.size()) m_last_selected = idx;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case coEnum: {
|
case coEnum: {
|
||||||
@ -1051,7 +1033,6 @@ void Choice::set_value(const boost::any& value, bool change_event)
|
|||||||
val = 0;
|
val = 0;
|
||||||
}
|
}
|
||||||
field->SetSelection(val);
|
field->SetSelection(val);
|
||||||
if (m_suppress_scroll) m_last_selected = val;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@ -1211,7 +1192,6 @@ void Choice::msw_rescale()
|
|||||||
idx == m_opt.enum_values.size() ?
|
idx == m_opt.enum_values.size() ?
|
||||||
field->SetValue(selection) :
|
field->SetValue(selection) :
|
||||||
field->SetSelection(idx);
|
field->SetSelection(idx);
|
||||||
if (m_suppress_scroll && idx < m_opt.enum_values.size()) m_last_selected = idx;
|
|
||||||
#else
|
#else
|
||||||
auto size = wxSize(def_width_wider() * m_em_unit, wxDefaultCoord);
|
auto size = wxSize(def_width_wider() * m_em_unit, wxDefaultCoord);
|
||||||
if (m_opt.height >= 0) size.SetHeight(m_opt.height * m_em_unit);
|
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
|
// parameters for an icon's drawing
|
||||||
fill_width_height();
|
fill_width_height();
|
||||||
Bind(wxEVT_COMBOBOX_DROPDOWN, [this](wxCommandEvent&) { m_suppress_change = false; });
|
|
||||||
Bind(wxEVT_COMBOBOX_CLOSEUP, [this](wxCommandEvent&) {
|
Bind(wxEVT_MOUSEWHEEL, [this](wxMouseEvent& e) {
|
||||||
// EVT_COMBOBOX_CLOSEUP is called after EVT_COMBOBOX on Windows
|
if (m_suppress_change)
|
||||||
// so, always set m_suppress_change to "true"
|
e.StopPropagation();
|
||||||
#ifndef __WXMSW__
|
else
|
||||||
if (m_last_selected == this->GetSelection())
|
e.Skip();
|
||||||
#endif //__WXMSW__
|
|
||||||
m_suppress_change = true;
|
|
||||||
});
|
});
|
||||||
|
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) {
|
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
||||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
||||||
@ -156,15 +156,6 @@ bool PresetComboBox::set_printer_technology(PrinterTechnology pt)
|
|||||||
return false;
|
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()
|
void PresetComboBox::invalidate_selection()
|
||||||
{
|
{
|
||||||
m_last_selected = INT_MAX; // this value means that no one item is selected
|
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))
|
PresetComboBox(parent, preset_type, wxSize(15 * wxGetApp().em_unit(), -1))
|
||||||
{
|
{
|
||||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent &evt) {
|
||||||
if (check_event_for_suppress_change(evt))
|
|
||||||
return;
|
|
||||||
auto selected_item = evt.GetSelection();
|
auto selected_item = evt.GetSelection();
|
||||||
|
|
||||||
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
auto marker = reinterpret_cast<Marker>(this->GetClientData(selected_item));
|
||||||
@ -579,7 +568,6 @@ PlaterPresetComboBox::PlaterPresetComboBox(wxWindow *parent, Preset::Type preset
|
|||||||
} else {
|
} else {
|
||||||
evt.StopPropagation();
|
evt.StopPropagation();
|
||||||
}
|
}
|
||||||
m_suppress_change = true;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (m_type == Preset::TYPE_FILAMENT)
|
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))
|
PresetComboBox(parent, preset_type, wxSize(35 * wxGetApp().em_unit(), -1))
|
||||||
{
|
{
|
||||||
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
Bind(wxEVT_COMBOBOX, [this](wxCommandEvent& evt) {
|
||||||
if (check_event_for_suppress_change(evt))
|
|
||||||
return;
|
|
||||||
// see https://github.com/prusa3d/PrusaSlicer/issues/3889
|
// 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")
|
// 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.
|
// 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();
|
evt.StopPropagation();
|
||||||
m_suppress_change = true;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,6 @@ protected:
|
|||||||
|
|
||||||
PrinterTechnology printer_technology {ptAny};
|
PrinterTechnology printer_technology {ptAny};
|
||||||
|
|
||||||
bool check_event_for_suppress_change(wxCommandEvent& evt);
|
|
||||||
void invalidate_selection();
|
void invalidate_selection();
|
||||||
void validate_selection(bool predicate = false);
|
void validate_selection(bool predicate = false);
|
||||||
void update_selection();
|
void update_selection();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user