mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
check mouse state before iterating through elements
This commit is contained in:
parent
9c9928d226
commit
83209e5e03
1 changed files with 62 additions and 53 deletions
|
@ -335,81 +335,90 @@ impl InnerInputState {
|
||||||
|
|
||||||
{
|
{
|
||||||
// mouseup
|
// mouseup
|
||||||
let mut will_bubble = FxHashSet::default();
|
if released {
|
||||||
for node in dom.get_listening_sorted("mouseup") {
|
let mut will_bubble = FxHashSet::default();
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
for node in dom.get_listening_sorted("mouseup") {
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
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)),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
dom,
|
dom,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// click
|
// click
|
||||||
let mut will_bubble = FxHashSet::default();
|
if mouse_data.button == 0 {
|
||||||
for node in dom.get_listening_sorted("click") {
|
let mut will_bubble = FxHashSet::default();
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
for node in dom.get_listening_sorted("click") {
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
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)),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
dom,
|
dom,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// contextmenu
|
// contextmenu
|
||||||
let mut will_bubble = FxHashSet::default();
|
if mouse_data.button == 2 {
|
||||||
for node in dom.get_listening_sorted("contextmenu") {
|
let mut will_bubble = FxHashSet::default();
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
for node in dom.get_listening_sorted("contextmenu") {
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
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)),
|
||||||
&mut will_bubble,
|
&mut will_bubble,
|
||||||
resolved_events,
|
resolved_events,
|
||||||
node,
|
node,
|
||||||
dom,
|
dom,
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// wheel
|
// wheel
|
||||||
let mut will_bubble = FxHashSet::default();
|
if let Some(w) = wheel_data {
|
||||||
for node in dom.get_listening_sorted("wheel") {
|
if wheel_delta != 0.0 {
|
||||||
let node_layout = layout.layout(node.state.layout.node.unwrap()).unwrap();
|
let mut will_bubble = FxHashSet::default();
|
||||||
let currently_contains = layout_contains_point(node_layout, new_pos);
|
for node in dom.get_listening_sorted("wheel") {
|
||||||
|
let node_layout =
|
||||||
|
layout.layout(node.state.layout.node.unwrap()).unwrap();
|
||||||
|
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()),
|
&mut will_bubble,
|
||||||
&mut will_bubble,
|
resolved_events,
|
||||||
resolved_events,
|
node,
|
||||||
node,
|
dom,
|
||||||
dom,
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue