Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: In mouse_area, move clearing of drag_initiated state to the beginning of the update fn #207

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions widget/src/mouse_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,22 @@ fn update<Message: Clone, Theme, Renderer>(
let state: &mut State = tree.state.downcast_mut();
let cursor_position = cursor.position();

if let Some(drag_source) = state.drag_initiated {
if let Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. }) = event
{
if let Some(position) = cursor_position {
if position.distance(drag_source) <= 1.0 {
state.drag_initiated = None;
}
}
}

if let Event::Touch(touch::Event::FingerLost { .. }) = event {
state.drag_initiated = None;
}
}

if let Event::Mouse(mouse::Event::CursorMoved { .. })
| Event::Touch(touch::Event::FingerMoved { .. }) = event
{
Expand Down Expand Up @@ -464,7 +480,6 @@ fn update<Message: Clone, Theme, Renderer>(
state.last_click = Some(click);
if let mouse::click::Kind::Double = click.kind() {
shell.publish(message.clone());
state.drag_initiated = None;
return event::Status::Captured;
}
}
Expand Down Expand Up @@ -510,7 +525,6 @@ fn update<Message: Clone, Theme, Renderer>(
if let Event::Mouse(mouse::Event::ButtonReleased(mouse::Button::Left))
| Event::Touch(touch::Event::FingerLifted { .. }) = event
{
state.drag_initiated = None;
shell.publish(message.clone());

return event::Status::Captured;
Expand Down
Loading