1st attempt to fix #1788

This commit is contained in:
Enrico Turri 2019-02-06 12:23:57 +01:00
parent 365f5297b1
commit 022b573bae

View File

@ -5332,14 +5332,21 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
// Set focus in order to remove it from sidebar fields // Set focus in order to remove it from sidebar fields
if (m_canvas != nullptr) { if (m_canvas != nullptr) {
// Only set focus, if the top level window of this canvas is active. // Only set focus, if the top level window of this canvas is active.
auto p = dynamic_cast<wxWindow*>(evt.GetEventObject()); auto p = dynamic_cast<wxWindow*>(evt.GetEventObject());
while (p->GetParent()) while (p->GetParent())
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
// 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
m_mouse.position = pos.cast<double>();
render();
}
}
m_mouse.set_start_position_2D_as_invalid(); m_mouse.set_start_position_2D_as_invalid();
//#endif //#endif
} }
@ -5493,10 +5500,10 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
} }
else if (evt.RightDown()) else if (evt.RightDown())
{ {
// forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while m_mouse.position = pos.cast<double>();
// the context menu is already shown, ensuring it to disappear if the mouse is outside any volume // // forces a frame render to ensure that m_hover_volume_id is updated even when the user right clicks while
m_mouse.position = Vec2d((double)pos(0), (double)pos(1)); // // the context menu is already shown, ensuring it to disappear if the mouse is outside any volume
render(); // render();
if (m_hover_volume_id != -1) if (m_hover_volume_id != -1)
{ {
// if right clicking on volume, propagate event through callback (shows context menu) // if right clicking on volume, propagate event through callback (shows context menu)
@ -5509,9 +5516,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT)); post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
_update_gizmos_data(); _update_gizmos_data();
wxGetApp().obj_manipul()->update_settings_value(m_selection); wxGetApp().obj_manipul()->update_settings_value(m_selection);
// forces a frame render to update the view before the context menu is shown // // forces a frame render to update the view before the context menu is shown
render(); // render();
Vec2d logical_pos = pos.cast<double>(); Vec2d logical_pos = pos.cast<double>();
#if ENABLE_RETINA_GL #if ENABLE_RETINA_GL
const float factor = m_retina_helper->get_scale_factor(); const float factor = m_retina_helper->get_scale_factor();