hcbpassos / drag_select_grid_view

A grid that supports both dragging and tapping to select its items.
BSD 2-Clause "Simplified" License
133 stars 34 forks source link

detect long press end #22

Closed christopher-inegbedion closed 3 years ago

christopher-inegbedion commented 3 years ago

Is it possible to detect when a drag is completed? I tried adding a GestureDetector as the parent widget but it just seems to break the DragSelectGridView widget.

hcbpassos commented 3 years ago

What do you mean by "break the DragSelectGridView widget"?

christopher-inegbedion commented 3 years ago

i mean the DragSelectGridView widget fails to respond to gestures when it has a GestureDetector as its parent. I looked through the code and noticed that the DragSelectGridView widget itself has a GestureDetector widget, but the onLongPressEnd event does not pass any information back to the user to indicate that the drag has been completed. Is this something you've given thought to, cause it seems like an obvious event that the user should be able to receive as a callback.

hcbpassos commented 3 years ago

i mean the DragSelectGridView widget fails to respond to gestures when it has a GestureDetector as its parent.

This is something the parent should be able to handle. By default, when you have nested GestureDetectors, only the child is going to receive the gesture events (HitTestBehavior.deferToChild). It's possible to send events to both child and parent by passing HitTestBehavior.translucent. The behavior you mentioned happens when you pass HitTestBehavior.opaque. I guess this is what you did?

Is this something you've given thought to, cause it seems like an obvious event that the user should be able to receive as a callback.

No, I haven't thought about exposing such information. May I ask you why do you need such feature? I feel like exposing such callback would imply I need to expose all the other ones: onTapUp, onLongPressStart, onLongPressMoveUpdate. After all, what makes the callback you mentioned particularly more important?

christopher-inegbedion commented 3 years ago

thanks for the help. i decided to use the Listener widget instead. By using the Listener widget i can just check for when the pointer is up. I read in the flutter docs that multiple cascaded GestureDetector widgets with the same event listener will clash and only 1 will run.

May I ask you why do you need such feature?

It's for a project i'm working on.