diff --git a/src/slic3r/GUI/GLCanvas3D.hpp b/src/slic3r/GUI/GLCanvas3D.hpp index 92819136a7..aa28fd6850 100644 --- a/src/slic3r/GUI/GLCanvas3D.hpp +++ b/src/slic3r/GUI/GLCanvas3D.hpp @@ -755,6 +755,12 @@ public: Size get_canvas_size() const; Vec2d get_local_mouse_position() const; + // store opening position of menu + std::optional m_popup_menu_positon; // position of mouse right click + void set_popup_menu_position(const Vec2d &position) { m_popup_menu_positon = position; } + const std::optional& get_popup_menu_position() const { return m_popup_menu_positon; } + void clear_popup_menu_position() { m_popup_menu_positon.reset(); } + void set_tooltip(const std::string& tooltip); // the following methods add a snapshot to the undo/redo stack, unless the given string is empty diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 21501d32d9..9875227bca 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -484,13 +484,17 @@ wxMenu* MenuFactory::append_submenu_add_generic(wxMenu* menu, ModelVolumeType ty [type, item](wxCommandEvent&) { obj_list()->load_generic_subobject(item, type); }, "", menu); } - auto add_text = [type](wxCommandEvent &) { - GLGizmosManager &mng = plater()->canvas3D()->get_gizmos_manager(); + auto add_text = [type](wxCommandEvent &evt) { + GLCanvas3D * canvas = plater()->canvas3D(); + GLGizmosManager &mng = canvas->get_gizmos_manager(); if ((mng.get_current_type() == GLGizmosManager::Emboss || mng.open_gizmo(GLGizmosManager::Emboss)) && type != ModelVolumeType::INVALID) { GLGizmoEmboss *emboss = dynamic_cast(mng.get_current()); - if (emboss != nullptr) emboss->create_volume(type); + if (emboss == nullptr) return; + auto screen_position = canvas->get_popup_menu_position(); + assert(screen_position.has_value()); + emboss->create_volume(type, *screen_position); } }; diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d60550d038..661c47d5d8 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -6876,7 +6876,9 @@ bool Plater::PopupMenu(wxMenu *menu, const wxPoint& pos) SuppressBackgroundProcessingUpdate sbpu; // When tracking a pop-up menu, postpone error messages from the slicing result. m_tracking_popup_menu = true; + canvas3D()->set_popup_menu_position(Vec2d(pos.x, pos.y)); bool out = this->wxPanel::PopupMenu(menu, pos); + canvas3D()->clear_popup_menu_position(); m_tracking_popup_menu = false; if (! m_tracking_popup_menu_error_message.empty()) { // Don't know whether the CallAfter is necessary, but it should not hurt.