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

Add long click and dragging support #7

Closed
wants to merge 1 commit into from
Closed

Conversation

mrichards42
Copy link
Collaborator

@raisjn, this is what got me to look at touch events again (from rmkit-dev/rmkit#74). I had a TODO in the mouse.down event to ignore multitouch.

I'm curious if you think gestures would be a better way to get at what I'm doing here, or if this extra layer on top of mouse events is its own thing. I'm not sure if this is something that would belong in rmkit -- it would be a fair amount of extra processing on top of every mouse event, so probably not something to support by default. But maybe there's something useful here. I'm not thrilled with the way GameScene has to keep the pointer to MouseManager -- it seems like it would be better to have the Widget be responsible, but that would mean reaching to rmkit internals 🤷

I'm looking to support a couple things:

  1. "dragging" events. once dragging is detected (a down followed by moving beyond a certain threshold), you get a drag_start event, then dragging events, then drag_end.
  2. long click vs short click. Long click is down + a configurable amount of delay + up. Short click is the same but without the delay. Both of these use the same threshold as dragging, and are only triggered when you haven't moved beyond that threshold.

@raisjn
Copy link
Member

raisjn commented Feb 2, 2021

cool!

i think it's fine for a widget to support draggable events in rmkit (but the drag manager is only installed if its turned on), i'd even like to support 'double click' events as well.

what is supposed to happen if a drag is initiated and you leave the widget? if the drag events are supposed to continue, then i'd consider this a gesture because Gestures are global, while widget events are usually not delivered if the event is outside the widget hitbox.

if it is a Gesture, there could be a WidgetDragGesture (or whatever name) which uses a widget's location as its start zone and the gesture can extend beyond the zone. i'm not sure if the gesture vocabulary will support what you want to achieve but i'm hopeful: it has filter(), handle() and finalize() API.

@mrichards42
Copy link
Collaborator Author

i think it's fine for a widget to support draggable events in rmkit (but the drag manager is only installed if its turned on), i'd even like to support 'double click' events as well.

Makes sense to me

what is supposed to happen if a drag is initiated and you leave the widget? if the drag events are supposed to continue, then i'd consider this a gesture because Gestures are global, while widget events are usually not delivered if the event is outside the widget hitbox.

In this case I just end the drag if it goes beyond the widget's hitbox, but I could definitely see something like drag and drop between widgets where the original widget needs to keep receiving events. In other tookits I'm familiar with the idea of "mouse capture", where a widget can request to be the only consumer of mouse events until capture is released. It's often used for drag-and-drop, since (a) the widget needs to keep getting events, and (b) other widgets should not get events while a drag is active. I haven't dug into Gestures, so I'm not sure how well that would translate, but I could see a global gesture being useful for this.

@raisjn
Copy link
Member

raisjn commented Feb 3, 2021

i think it's reasonable to bring this to rmkit as drag events, but up to you. if yes, input_demo is a good place to put the demo code

In other tookits I'm familiar with the idea of "mouse capture", where a widget can request to be the only consumer of mouse events until capture is released. It's often used for drag-and-drop, since (a) the widget needs to keep getting events, and (b) other widgets should not get events while a drag is active. I haven't dug into Gestures, so I'm not sure how well that would translate, but I could see a global gesture being useful for this.

capture sounds easier than gestures - i think it means that the main_loop would just dispatch events to the captured widget, but maybe there are some drag events that need to go to both widgets.

@mrichards42
Copy link
Collaborator Author

i think it's reasonable to bring this to rmkit as drag events, but up to you. if yes, input_demo is a good place to put the demo code

cool, I'll give this a shot in the next week or so.

@mrichards42 mrichards42 mentioned this pull request Feb 12, 2021
@mrichards42
Copy link
Collaborator Author

closed in favor of rmkit-dev/rmkit#87

@mrichards42 mrichards42 deleted the mouse-manager branch February 19, 2021 19:18
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.

2 participants