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

Publish DragEvent::Canceled always when picked Pane is dropped outside valid target area #2654

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jsatka
Copy link

@jsatka jsatka commented Oct 31, 2024

Currently a pane_grid::DragEvent::Canceled is not published when a picked pane_grid::Pane is dropped near the origin point where it was picked up (closer than DRAG_DEADBAND_DISTANCE) or outside the window. However in both cases in the pane grid state pane_grid::Memory the action state gets set from Action::Dragging to Action::Idle i.e. cancelling the dragging action.

As such, clicking a pane title bar produces DragEvent::Picked event but not subsequent DragEvent::Canceled, leaving a user who needs to track the dragging state thinking the pane is being dragged while it is not.

This change adds publishing Canceled variant in the aforementioned cases. Thus, dropping a picked pane will always produce either Dropped or Canceled variant depending whether the drop point was a valid pane_grid:::Target area.

@jsatka
Copy link
Author

jsatka commented Oct 31, 2024

Easy way to test this is to run the pane_grid example with the following changes to Message handling to print all drag events to console:

            Message::Dragged(pane_grid::DragEvent::Picked { pane }) => {
                println!("{:?} drag started", pane);
            }
            Message::Dragged(pane_grid::DragEvent::Dropped {
                pane,
                target,
            }) => {
                self.panes.drop(pane, target);
                println!("{:?} drag dropped", pane);
            }
            Message::Dragged(pane_grid::DragEvent::Canceled { pane }) => {
                println!("{:?} drag canceled", pane);
            }

and then testing:

  • clicking the pane title bars
  • dragging and dropping panes outside the window

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant