StarArawn / kayak_ui

Other
469 stars 50 forks source link

Adding more click functionality #275

Closed TheTacBanana closed 1 year ago

TheTacBanana commented 1 year ago

Adds the ability to detect Right and Middle click on widgets.

Changes are breaking due to changes of Enum names. But relatively easy to fix existing code.

Existing:

if let EventType::Click(..) = event.event_type {
    ...
}       

New:

if let EventType::LeftClick(..) = event.event_type {
    ...
}       
ethereumdegen commented 1 year ago

IMO this could be cleaner and more backwards compatible to add a 'button type' to CursorEvent struct and leave the EventType Enum the way it was.

This way, if i want to do something on a left OR right click, i wont have to implement 2 different children in a match statement. I can just check to see if the button type in cursorevent inside of 'MouseDown' is LEFT or RIGHT.

im going to make a PR based on yours with this alternative topology so hold off until we can look at both and compare pls.

ethereumdegen commented 1 year ago

okay please see PR #276 it is built off of this one. That PR offers the same functionality, using many of your lines of code but instead of adding new EventTypes it just adds a 'button type' prop to the CursorEvent struct. This way the examples don't even have to change and it doesn't break anyones existing codebases but still offers all the same benefits of being able to detect which mouse button has been pressed.

TheTacBanana commented 1 year ago

Definitely a better way of implementing it, not sure why I didn't do that myself. I'm in favor of your PR, much simpler.