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

More click events simpler #276

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

ethereumdegen
Copy link

@ethereumdegen ethereumdegen commented Jul 26, 2023

This builds off of @TheTacBanana 's pr #275 . It offers the same functionality as that one (and uses much of the code of that pr) but executes it in a slightly more streamlined design by not changing the EventType enum at all but instead simply adding a 'button' enum to the CursorEvent struct.

This means the examples dont need to change and existing user code doesnt break and you can still detect which mouse button has been pressed by reading the struct.

#[derive( Debug, Copy, Clone, PartialEq)] pub struct CursorEvent { pub pressed: bool, pub just_pressed: bool, pub just_released: bool, pub position: (f32, f32), pub mouse_button: MouseButton // new }

@TheTacBanana
Copy link

Definitely agree that this is the better and simpler approach compared to mine, I extended your approach a bit to support any number of mouse buttons rather than being limited to just Left, Right & Middle. Also removes a bunch of the duplicated code.

https://github.com/TheTacBanana/kayak_ui/tree/n-mouse-button-support

Although might be taking it a bit far, not sure if anyone will ever want to detect when their forward button has been clicked on an element.

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