py5coding / py5generator

Meta-programming project that creates the py5 library code.
https://py5coding.org/
GNU General Public License v3.0
52 stars 13 forks source link

Possible alias for .getCount() method of the mouse_wheel event #64

Closed villares closed 2 years ago

villares commented 2 years ago

When creating a mouse_wheel event function, it receives an event object. It could be nice to have .get_count() as a method alias, maybe...

image

hx2A commented 2 years ago

This is a good idea and an easy thing to change. Thanks for pointing this out!!

hx2A commented 2 years ago

I sat down today ready to write the "easy thing to change" and I discovered a proper solution for this is more complex but will be a worthwhile enhancement. If it was just getCount() => get_count() it would be easy, but there is more to it.

Looking at the Processing documentation, I see the syntax for the user-defined mouseWheel method is mouseWheel(event), but when I look at the other user-defined mouse or keyboard defined events such as mouseDragged I see the syntax can be mouseDragged() or mouseDragged(event). Same thing for keyPressed, and many others They can all optionally be passed an event object.

Right now, py5 only passes the event object to a user-defined mouse_wheel function, and the function must take that argument, it is not optional. There is no way for the other user-defined key and mouse functions to get the KeyEvent or MouseEvent objects, and I think it would be great if it did.

Implementing a proper enhancement for this isn't that big of a change but it will be a bit involved. Since I aspire to get a release out next week, I am going to defer this to the next release when I have more time.

hx2A commented 2 years ago

Also I'll point out I noticed in the Processing code that there is a prototype TouchEvent object and I want py5 to be prepared for for that when touch events get added to Processing!

hx2A commented 2 years ago

Started working on this, will definitely be in the next release

hx2A commented 2 years ago

The coding is done! This works perfectly. Now I just need to write the docstrings and example code.

hx2A commented 2 years ago

All done. Will start thinking about the next release.