fix mouse capture bug
This commit is contained in:
@@ -286,12 +286,19 @@ glm::vec4 Node::get_children_rect() const
|
|||||||
|
|
||||||
void Node::mouse_capture()
|
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)
|
if (auto n = root()->current_mouse_capture)
|
||||||
{
|
{
|
||||||
MouseEvent e;
|
MouseEvent e;
|
||||||
e.m_type = kEventType::MouseCancel;
|
e.m_type = kEventType::MouseCancel;
|
||||||
n->handle_event(&e);
|
n->handle_event(&e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// make current
|
||||||
root()->current_mouse_capture = this;
|
root()->current_mouse_capture = this;
|
||||||
m_mouse_captured = true;
|
m_mouse_captured = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -284,4 +284,5 @@ void NodeCanvas::reset_camera()
|
|||||||
m_canvas->m_cam_rot = {0, 0};
|
m_canvas->m_cam_rot = {0, 0};
|
||||||
m_canvas->m_cam_pos = {0, 0, 0};
|
m_canvas->m_cam_pos = {0, 0, 0};
|
||||||
m_canvas->m_cam_fov = 85;
|
m_canvas->m_cam_fov = 85;
|
||||||
|
m_canvas->m_pan = {0, 0};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user