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

additional mouse_enter and mouse_exit functions? #61

Open
ben-wes opened this issue Oct 15, 2024 · 9 comments · May be fixed by #70
Open

additional mouse_enter and mouse_exit functions? #61

ben-wes opened this issue Oct 15, 2024 · 9 comments · May be fixed by #70

Comments

@ben-wes
Copy link
Contributor

ben-wes commented Oct 15, 2024

the mouse_move(x, y) callback can be used to create hover feedback in pdlua GUI objects.

unfortunately, this has one major restriction though: the position is only reported on changes inside the object box and these changes are not necessarily reporting continuous coordinates. so there's no way to reliably determine whether the mouse has left the object area (or "crossed a border").

one option to deal with this might be additional functions. i learnt that @timothyschoen had these implemented some time ago and then removed them again since they seemed slightly hacky for vanilla. maybe they could be reconsidered though since they would allow for some additional interaction patterns.

one question in this context is whether mouse_enter and mouse_exit could also be achieved easily with purr data?

@Gorachand-Senapati
Copy link

hey maintainer can I work on the issue

@timothyschoen
Copy link
Contributor

hey maintainer can I work on the issue

Not the maintainer, but if you want get started, I recommend looking at how else's [canvas.mouse] object works:

https://github.com/porres/pd-else/blob/9e5c2a23a77e9d413f03f283d9c6460203040217/Source/Control/canvas.mouse.c

@ben-wes

This comment has been minimized.

@ben-wes
Copy link
Contributor Author

ben-wes commented Dec 25, 2024

just noting here that in this context, it might be also nice to report the mouse_up() outside the object boundaries (after a mouse_down() inside) - not completely sure about that though.

@timothyschoen
Copy link
Contributor

timothyschoen commented Dec 25, 2024

just noting here that in this context, it might be also nice to report the mouse_up() outside the object boundaries (after a mouse_down() inside) - not completely sure about that though.

Yes, I agree with this. I think the plugdata version might actually already do this, since this is how mouse events behave in JUCE. It's good if we can guarantee that every "mouse_down" will be followed by a "mouse_up", it makes it easier to write dragging logic.

edit:
Testing in plugdata, it indeed already does this.
pd-vanilla seems to do it too, except if you drag the mouse outside of the pd window. But it does seem like mouse_up still gets sent if the mouse is outside of object bounds.

@ben-wes

This comment has been minimized.

@ben-wes
Copy link
Contributor Author

ben-wes commented Dec 25, 2024

But it does seem like mouse_up still gets sent if the mouse is outside of object bounds.

tested this again here and i'm a bit irritated since i can't confirm it. mouse_up() is only called when there's an additional movement (unlike mouse_down() that fires directly when pressing the button) - and it only fires when the cursor is in the object boundaries for me.

this differs between plugdata and puredata though.

attaching a simple test object and patch: mouse_test.zip

@ben-wes

This comment has been minimized.

@ben-wes
Copy link
Contributor Author

ben-wes commented Jan 16, 2025

i created #70 now as a first draft for Pd vanilla. but it really feels a bit hacky with that canvas message proxy ...

2025-01-16.22-29-28.mp4

some details (possibly for discussion):

  • mouse_enter() and mouse_exit() are not called while dragging
  • on mouse_up() after dragging outside, mouse_up() and mouse_exit() are called immediately

@ben-wes ben-wes linked a pull request Jan 16, 2025 that will close this issue
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 a pull request may close this issue.

3 participants