fix mouse capture bug

This commit is contained in:
2017-08-19 16:59:05 +01:00
parent da4bfff69b
commit a2b888efd6
2 changed files with 8 additions and 0 deletions

View File

@@ -286,12 +286,19 @@ glm::vec4 Node::get_children_rect() const
void Node::mouse_capture()
{
// already owner of capture
if (root()->current_mouse_capture == this)
return;
// cancel previous owner
if (auto n = root()->current_mouse_capture)
{
MouseEvent e;
e.m_type = kEventType::MouseCancel;
n->handle_event(&e);
}
// make current
root()->current_mouse_capture = this;
m_mouse_captured = true;
}

View File

@@ -284,4 +284,5 @@ void NodeCanvas::reset_camera()
m_canvas->m_cam_rot = {0, 0};
m_canvas->m_cam_pos = {0, 0, 0};
m_canvas->m_cam_fov = 85;
m_canvas->m_pan = {0, 0};
}