Yet another fix of keyboard / mouse focus on the 3D scene.
This commit is contained in:
parent
0f96213dce
commit
f3b33eac50
1 changed files with 15 additions and 9 deletions
|
@ -4843,6 +4843,7 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
#endif // ENABLE_IMGUI
|
#endif // ENABLE_IMGUI
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
bool on_enter_workaround = false;
|
bool on_enter_workaround = false;
|
||||||
if (! evt.Entering() && ! evt.Leaving() && m_mouse.position.x() == -1.0) {
|
if (! evt.Entering() && ! evt.Leaving() && m_mouse.position.x() == -1.0) {
|
||||||
// Workaround for SPE-832: There seems to be a mouse event sent to the window before evt.Entering()
|
// Workaround for SPE-832: There seems to be a mouse event sent to the window before evt.Entering()
|
||||||
|
@ -4852,7 +4853,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
printf((format_mouse_event_debug_message(evt) + " - OnEnter workaround\n").c_str());
|
printf((format_mouse_event_debug_message(evt) + " - OnEnter workaround\n").c_str());
|
||||||
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
||||||
on_enter_workaround = true;
|
on_enter_workaround = true;
|
||||||
} else {
|
} else
|
||||||
|
#endif /* __WXMSW__ */
|
||||||
|
{
|
||||||
#ifdef SLIC3R_DEBUG_MOUSE_EVENTS
|
#ifdef SLIC3R_DEBUG_MOUSE_EVENTS
|
||||||
printf((format_mouse_event_debug_message(evt) + " - other\n").c_str());
|
printf((format_mouse_event_debug_message(evt) + " - other\n").c_str());
|
||||||
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
#endif /* SLIC3R_DEBUG_MOUSE_EVENTS */
|
||||||
|
@ -4876,6 +4879,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
}
|
}
|
||||||
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
#endif // ENABLE_MOVE_MIN_THRESHOLD
|
||||||
|
|
||||||
|
if (evt.ButtonDown() && wxWindow::FindFocus() != this->m_canvas)
|
||||||
|
// Grab keyboard focus on any mouse click event.
|
||||||
|
m_canvas->SetFocus();
|
||||||
|
|
||||||
if (evt.Entering())
|
if (evt.Entering())
|
||||||
{
|
{
|
||||||
//#if defined(__WXMSW__) || defined(__linux__)
|
//#if defined(__WXMSW__) || defined(__linux__)
|
||||||
|
@ -4888,15 +4895,12 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
p = p->GetParent();
|
p = p->GetParent();
|
||||||
auto *top_level_wnd = dynamic_cast<wxTopLevelWindow*>(p);
|
auto *top_level_wnd = dynamic_cast<wxTopLevelWindow*>(p);
|
||||||
if (top_level_wnd && top_level_wnd->IsActive())
|
if (top_level_wnd && top_level_wnd->IsActive())
|
||||||
{
|
|
||||||
m_canvas->SetFocus();
|
m_canvas->SetFocus();
|
||||||
|
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
|
||||||
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
|
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
|
||||||
// the context menu is shown, ensuring it to disappear if the mouse is outside any volume and to
|
// change the volume hover state if any is under the mouse
|
||||||
// change the volume hover state if any is under the mouse
|
m_mouse.position = pos.cast<double>();
|
||||||
m_mouse.position = pos.cast<double>();
|
render();
|
||||||
render();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
m_mouse.set_start_position_2D_as_invalid();
|
m_mouse.set_start_position_2D_as_invalid();
|
||||||
//#endif
|
//#endif
|
||||||
|
@ -5305,8 +5309,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
||||||
else
|
else
|
||||||
evt.Skip();
|
evt.Skip();
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
if (on_enter_workaround)
|
if (on_enter_workaround)
|
||||||
m_mouse.position = Vec2d(-1., -1.);
|
m_mouse.position = Vec2d(-1., -1.);
|
||||||
|
#endif /* __WXMSW__ */
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLCanvas3D::on_paint(wxPaintEvent& evt)
|
void GLCanvas3D::on_paint(wxPaintEvent& evt)
|
||||||
|
|
Loading…
Reference in a new issue