-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Add event for clicks #9047
Copy link
Copy link
Closed
Labels
A-PickingPointing at and selecting objects of all sortsPointing at and selecting objects of all sortsA-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use
Metadata
Metadata
Assignees
Labels
A-PickingPointing at and selecting objects of all sortsPointing at and selecting objects of all sortsA-UIGraphical user interfaces, styles, layouts, and widgetsGraphical user interfaces, styles, layouts, and widgetsC-UsabilityA targeted quality-of-life change that makes Bevy easier to useA targeted quality-of-life change that makes Bevy easier to use
What problem does this solve or what need does it fill?
Recently we renamed
Interaction::ClickintoInteraction::Pressedand it makes a lot of sense. But we still don't have mechanism for actual clicks. It's different from button press: it's a transition from pressed and released state when the cursor stays on the button.What solution would you like?
I would suggest to introduce event
struct Click(Entity)event that contains the clicked entity.Additional context
It's very simple to implement, here is the implementation from my game. The event happens on transition from
Interaction::ClickedtoInteraction::Hovered, you don't even need to check the mouse position,Interaction::Hoveredgives it's to you for free.If we implement it, we need to change the example to check for click instead of button press.
@AnthonyKalaitzis you may be interested in implementing this.