From e277e5915ed2f43a25c9e8b988e5e046bd18c903 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Mon, 2 Oct 2023 10:11:26 +0200 Subject: [PATCH] Fix for SPE-1927 : Focus on Canvas entering --- src/slic3r/GUI/GLCanvas3D.cpp | 45 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index f29424b4cd..7d9896f19f 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -1,13 +1,13 @@ -///|/ Copyright (c) Prusa Research 2018 - 2023 Enrico Turri @enricoturri1966, Oleksandra Iushchenko @YuSanka, Tomáš Mészáros @tamasmeszaros, Lukáš Matěna @lukasmatena, Vojtěch Bubník @bubnikv, David Kocík @kocikdav, Filip Sykala @Jony01, Lukáš Hejl @hejllukas, Vojtěch Král @vojtechkral -///|/ Copyright (c) BambuStudio 2023 manch1n @manch1n -///|/ Copyright (c) SuperSlicer 2023 Remi Durand @supermerill -///|/ Copyright (c) 2020 Benjamin Greiner -///|/ Copyright (c) 2019 John Drake @foxox -///|/ Copyright (c) 2019 BeldrothTheGold @BeldrothTheGold -///|/ Copyright (c) 2019 Thomas Moore -///|/ -///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher -///|/ +///|/ Copyright (c) Prusa Research 2018 - 2023 Enrico Turri @enricoturri1966, Oleksandra Iushchenko @YuSanka, Tomáš Mészáros @tamasmeszaros, Lukáš Matěna @lukasmatena, Vojtěch Bubník @bubnikv, David Kocík @kocikdav, Filip Sykala @Jony01, Lukáš Hejl @hejllukas, Vojtěch Král @vojtechkral +///|/ Copyright (c) BambuStudio 2023 manch1n @manch1n +///|/ Copyright (c) SuperSlicer 2023 Remi Durand @supermerill +///|/ Copyright (c) 2020 Benjamin Greiner +///|/ Copyright (c) 2019 John Drake @foxox +///|/ Copyright (c) 2019 BeldrothTheGold @BeldrothTheGold +///|/ Copyright (c) 2019 Thomas Moore +///|/ +///|/ PrusaSlicer is released under the terms of the AGPLv3 or higher +///|/ #include "libslic3r/libslic3r.h" #include "GLCanvas3D.hpp" @@ -3617,20 +3617,19 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) //#if defined(__WXMSW__) || defined(__linux__) // // On Windows and Linux needs focus in order to catch key events - // Set focus in order to remove it from object list if (m_canvas != nullptr) { - // Only set focus, if the top level window of this canvas is active - // and ObjectList has a focus - auto p = dynamic_cast(evt.GetEventObject()); - while (p->GetParent()) - p = p->GetParent(); -#ifdef __WIN32__ - wxWindow* const obj_list = wxGetApp().obj_list()->GetMainWindow(); -#else - wxWindow* const obj_list = wxGetApp().obj_list(); -#endif - if (obj_list == p->FindFocus()) - m_canvas->SetFocus(); + + // Set focus in order to remove it from sidebar but not from TextControl (in ManipulationPanel f.e.) + if (!m_canvas->HasFocus()) { + wxTopLevelWindow* tlw = find_toplevel_parent(m_canvas); + // Only set focus, if the top level window of this canvas is active + if (tlw->IsActive()) { + auto* text_ctrl = dynamic_cast(tlw->FindFocus()); + if (text_ctrl == nullptr) + m_canvas->SetFocus(); + } + } + m_mouse.position = pos.cast(); m_tooltip_enabled = false; // 1) forces a frame render to ensure that m_hover_volume_idxs is updated even when the user right clicks while