diff --git a/data/layout.xml b/data/layout.xml
index 84da5fb..011c94e 100644
--- a/data/layout.xml
+++ b/data/layout.xml
@@ -307,7 +307,7 @@
-
+
@@ -324,7 +324,7 @@
-
+
@@ -391,7 +391,7 @@
-
+
@@ -412,7 +412,7 @@
-
+
@@ -442,7 +442,7 @@
-
+
@@ -474,7 +474,7 @@
-
+
@@ -501,7 +501,7 @@
-
+
@@ -530,7 +530,7 @@
-
+
@@ -553,7 +553,7 @@
-
+
@@ -578,7 +578,7 @@
-
+
@@ -616,7 +616,7 @@
-
+
@@ -677,7 +677,7 @@ Roboto Font License:
-
+
@@ -753,7 +753,7 @@ Here's a list of what's available in this release.
-
+
@@ -996,7 +996,7 @@ Here's a list of what's available in this release.
-
+
-
+
-
+
diff --git a/src/node.cpp b/src/node.cpp
index 561d4e0..8e0058f 100644
--- a/src/node.cpp
+++ b/src/node.cpp
@@ -132,7 +132,7 @@ kEventResult Node::on_event(Event* e)
case kEventType::MouseDownR:
case kEventType::MouseUpL:
case kEventType::MouseUpR:
- if ((inside || m_mouse_captured) && handle_event(e) == kEventResult::Consumed)
+ if ((inside || m_mouse_captured) && (handle_event(e) == kEventResult::Consumed || m_force_mouse_capture))
return kEventResult::Consumed;
break;
case kEventType::MouseMove:
@@ -143,7 +143,11 @@ kEventResult Node::on_event(Event* e)
handle_event(&e2);
}
if (inside || m_mouse_captured)
+ {
ret = handle_event(e);
+ if (m_force_mouse_capture)
+ ret = kEventResult::Consumed;
+ }
if (inside_old == true && inside == false)
{
MouseEvent e2 = *me;
@@ -419,6 +423,7 @@ Node::Node(Node&& o)
m_mvp = o.m_mvp;
m_mouse_inside = o.m_mouse_inside;
m_flood_events = o.m_flood_events;
+ m_force_mouse_capture = o.m_force_mouse_capture;
m_capture_children = o.m_capture_children;
m_destroyed = o.m_destroyed;
@@ -855,7 +860,10 @@ void Node::parse_attributes(kAttribute ka, const tinyxml2::XMLAttribute* attr)
break;
}
case kAttribute::FloodEvents:
- m_flood_events = attr->IntValue() > 0;
+ m_flood_events = attr->BoolValue();
+ break;
+ case kAttribute::MouseCapture:
+ m_force_mouse_capture = attr->BoolValue();
break;
case kAttribute::AspectRatio:
YGNodeStyleSetAspectRatio(y_node, attr->FloatValue());
@@ -1003,6 +1011,7 @@ void Node::clone_copy(Node* dest) const
dest->m_size = m_size;
dest->m_clip = m_clip;
dest->m_flood_events = m_flood_events;
+ dest->m_force_mouse_capture = m_force_mouse_capture;
dest->m_manager = m_manager;
dest->current_mouse_capture = current_mouse_capture;
diff --git a/src/node.h b/src/node.h
index b5b2df2..8fd33cf 100644
--- a/src/node.h
+++ b/src/node.h
@@ -45,6 +45,7 @@ enum class kAttribute : uint16_t
Default = const_hash("default"),
RTL = const_hash("rtl"),
AutoSize = const_hash("autosize"),
+ MouseCapture = const_hash("mouse-capture"),
};
enum class kWidget : uint16_t
@@ -107,6 +108,7 @@ public:
glm::mat4 m_mvp;
bool m_mouse_inside = false;
bool m_flood_events = false;
+ bool m_force_mouse_capture = false;
bool m_capture_children = true; // wether to capture children events when xx_capture() is used
bool m_destroyed = false;