From 252f9302efea1fd6e32bca584f9d13c631f9a4ad Mon Sep 17 00:00:00 2001 From: YuSanka Date: Thu, 10 Nov 2022 11:22:29 +0100 Subject: [PATCH] Suppress to delete object from 3D-Scene, when ObjectList is in Editing mode --- src/slic3r/GUI/GUI_ObjectList.cpp | 10 +++++----- src/slic3r/GUI/GUI_ObjectList.hpp | 5 +++-- src/slic3r/GUI/Plater.cpp | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/slic3r/GUI/GUI_ObjectList.cpp b/src/slic3r/GUI/GUI_ObjectList.cpp index abb22392b3..517b4a704e 100644 --- a/src/slic3r/GUI/GUI_ObjectList.cpp +++ b/src/slic3r/GUI/GUI_ObjectList.cpp @@ -216,9 +216,7 @@ ObjectList::ObjectList(wxWindow* parent) : Bind(wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE, &ObjectList::OnDropPossible, this); Bind(wxEVT_DATAVIEW_ITEM_DROP, &ObjectList::OnDrop, this); -#ifdef __WXMSW__ Bind(wxEVT_DATAVIEW_ITEM_EDITING_STARTED, &ObjectList::OnEditingStarted, this); -#endif /* __WXMSW__ */ Bind(wxEVT_DATAVIEW_ITEM_EDITING_DONE, &ObjectList::OnEditingDone, this); Bind(wxEVT_DATAVIEW_ITEM_VALUE_CHANGED, &ObjectList::ItemValueChanged, this); @@ -4621,17 +4619,19 @@ void ObjectList::ItemValueChanged(wxDataViewEvent &event) } } +void ObjectList::OnEditingStarted(wxDataViewEvent &event) +{ + m_is_editing_started = true; #ifdef __WXMSW__ // Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected. // Here the last active column is forgotten, so when leaving the editing mode, the next mouse click will not enter the editing mode of the newly selected column. -void ObjectList::OnEditingStarted(wxDataViewEvent &event) -{ m_last_selected_column = -1; -} #endif //__WXMSW__ +} void ObjectList::OnEditingDone(wxDataViewEvent &event) { + m_is_editing_started = false; if (event.GetColumn() != colName) return; diff --git a/src/slic3r/GUI/GUI_ObjectList.hpp b/src/slic3r/GUI/GUI_ObjectList.hpp index eb718b48d4..f98f091ddc 100644 --- a/src/slic3r/GUI/GUI_ObjectList.hpp +++ b/src/slic3r/GUI/GUI_ObjectList.hpp @@ -175,6 +175,7 @@ private: // Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected. int m_last_selected_column = -1; #endif /* __MSW__ */ + bool m_is_editing_started{ false }; #if 0 SettingsFactory::Bundle m_freq_settings_fff; @@ -404,6 +405,8 @@ public: void apply_volumes_order(); bool has_paint_on_segmentation(); + bool is_editing() const { return m_is_editing_started; } + private: #ifdef __WXOSX__ // void OnChar(wxKeyEvent& event); @@ -417,10 +420,8 @@ private: bool can_drop(const wxDataViewItem& item) const ; void ItemValueChanged(wxDataViewEvent &event); -#ifdef __WXMSW__ // Workaround for entering the column editing mode on Windows. Simulate keyboard enter when another column of the active line is selected. void OnEditingStarted(wxDataViewEvent &event); -#endif /* __WXMSW__ */ void OnEditingDone(wxDataViewEvent &event); }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index ccaf28ec0f..3204def994 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -4880,12 +4880,12 @@ void Plater::priv::set_bed_shape(const Pointfs& shape, const double max_print_he bool Plater::priv::can_delete() const { - return !get_selection().is_empty() && !get_selection().is_wipe_tower(); + return !get_selection().is_empty() && !get_selection().is_wipe_tower() && !sidebar->obj_list()->is_editing(); } bool Plater::priv::can_delete_all() const { - return !model.objects.empty(); + return !model.objects.empty() && !sidebar->obj_list()->is_editing(); } bool Plater::priv::can_fix_through_netfabb() const