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;
}