additional `mouse_enter` and `mouse_exit` functions?
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?
hey maintainer can I work on the issue
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
hey maintainer can I work on the issue
@Gorachand-Senapati just curious: did you start working on this?
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.
just noting here that in this context, it might be also nice to report the
mouse_up()outside the object boundaries (after amouse_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.
But it does seem like mouse_up still gets sent if the mouse is outside of object bounds.
ah damn. I was too quickly making false assumptions while experimenting with "long distance dragging". thanks for your tests!
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
not sure if the issue of the held back mouse_up() can be easily solved here (i admittedly don't completely understand the logic):
https://github.com/agraef/pd-lua/blob/4301f744a9023ea77b6fe0ba35918ad18e19276f/pdlua.c#L826-L833
maybe we should adapt more of the event handling in https://github.com/porres/pd-else/blob/9e5c2a23a77e9d413f03f283d9c6460203040217/Source/Control/canvas.mouse.c ? (or similarly https://github.com/iem-projects/pd-iemguts/blob/main/src/receivecanvas.c )
i created #70 now as a first draft for Pd vanilla. but it really feels a bit hacky with that canvas message proxy ...
https://github.com/user-attachments/assets/e2e1c4cd-2b04-4b6f-83c8-9235bcb9e77b
some details (possibly for discussion):
-
mouse_enter()andmouse_exit()are not called while dragging - on
mouse_up()after dragging outside,mouse_up()andmouse_exit()are called immediately