check mouse state before iterating through elements
This commit is contained in:
1 parent
9c9928d226
commit
83209e5e03
1 file changed
+15
-6
@@ -335,12 +335,13 @@ impl InnerInputState {
|
|||||||
|
|
||||||
{
|
{
|
||||||
// mouseup
|
// mouseup
|
||||||
|
if released {
|
||||||
let mut will_bubble = FxHashSet::default();
|
let mut will_bubble = FxHashSet::default();
|
||||||
for node in dom.get_listening_sorted("mouseup") {
|
for node in dom.get_listening_sorted("mouseup") {
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
if currently_contains && released {
|
if currently_contains {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"mouseup",
|
"mouseup",
|
||||||
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
||||||
@@ -352,15 +353,17 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// click
|
// click
|
||||||
|
if mouse_data.button == 0 {
|
||||||
let mut will_bubble = FxHashSet::default();
|
let mut will_bubble = FxHashSet::default();
|
||||||
for node in dom.get_listening_sorted("click") {
|
for node in dom.get_listening_sorted("click") {
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
if currently_contains && released && mouse_data.button == 0 {
|
if currently_contains && released {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"click",
|
"click",
|
||||||
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
||||||
@@ -372,15 +375,17 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// contextmenu
|
// contextmenu
|
||||||
|
if mouse_data.button == 2 {
|
||||||
let mut will_bubble = FxHashSet::default();
|
let mut will_bubble = FxHashSet::default();
|
||||||
for node in dom.get_listening_sorted("contextmenu") {
|
for node in dom.get_listening_sorted("contextmenu") {
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
if currently_contains && released && mouse_data.button == 2 {
|
if currently_contains && released {
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"contextmenu",
|
"contextmenu",
|
||||||
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
Arc::new(prepare_mouse_data(mouse_data, node_layout)),
|
||||||
@@ -392,16 +397,19 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// wheel
|
// wheel
|
||||||
|
if let Some(w) = wheel_data {
|
||||||
|
if wheel_delta != 0.0 {
|
||||||
let mut will_bubble = FxHashSet::default();
|
let mut will_bubble = FxHashSet::default();
|
||||||
for node in dom.get_listening_sorted("wheel") {
|
for node in dom.get_listening_sorted("wheel") {
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
let node_layout =
|
||||||
|
layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let currently_contains = layout_contains_point(node_layout, new_pos);
|
||||||
|
|
||||||
if let Some(w) = wheel_data {
|
if currently_contains {
|
||||||
if currently_contains && wheel_delta != 0.0 {
|
|
||||||
try_create_event(
|
try_create_event(
|
||||||
"wheel",
|
"wheel",
|
||||||
Arc::new(w.clone()),
|
Arc::new(w.clone()),
|
||||||
@@ -414,6 +422,7 @@ impl InnerInputState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// mouseleave
|
// mouseleave
|
||||||
|
|||||||
Reference in new issue
Block a user