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

Add Interaction::Released (Detect the release of a UIButton) #7240

Closed
wants to merge 2 commits into from

Conversation

Weibye
Copy link
Contributor

@Weibye Weibye commented Jan 16, 2023

Objective

Fix #5769

Solution

Change to Interaction::Released instead of Interaction::None for 1 frame as the button is released.


Changelog

Added

  • Interaction now be considered Interaction::Released for 1 frame when the user has released interaction on the button.

Feedback Wanted / Unresolved Questions

This solution relies on the ui_focus system running for 1 more frame after the interaction has been released, meaning that it does not work currently work when using the "DesktopMode" winit setting that only runs systems when user-input has occurred. It will be stuck in "Released" state until some new input is provided by the user.

Any ideas as to how that can be solved?

@Weibye Weibye added C-Feature A new feature, making something new possible A-UI Graphical user interfaces, styles, layouts, and widgets labels Jan 16, 2023
@@ -37,6 +37,8 @@ use smallvec::SmallVec;
pub enum Interaction {
/// The node has been clicked
Clicked,
/// The node has been released from
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// The node has been released from
/// The node has just been released

@alice-i-cecile alice-i-cecile added this to the 0.10 milestone Jan 16, 2023
@alice-i-cecile
Copy link
Member

This solution relies on the ui_focus system running for 1 more frame after the interaction has been released, meaning that it does not work currently work when using the "DesktopMode" winit setting that only runs systems when user-input has occurred. It will be stuck in "Released" state until some new input is provided by the user.

That's pretty unfortunate. We could add another system at the end of the frame to reset them? Or run for two frames on interaction in DesktopMode.

@Weibye
Copy link
Contributor Author

Weibye commented Jan 16, 2023

We could add another system at the end of the frame to reset them?

When does input reset their "just_pressed" / "just_released" states? Is it within the same frame but at the end of the update stage?

@Weibye Weibye changed the title Detect the release of a button Add Interaction::Released (Detect the release of a UIButton) Jan 16, 2023
@alice-i-cecile
Copy link
Member

When does input reset their "just_pressed" / "just_released" states? Is it within the same frame but at the end of the update stage?

Near the start of each frame in PreUpdate. I actually think this is a bit of a mistake, as it wreaks havoc with things like fixed time steps, but that's the current strategy.

@alice-i-cecile alice-i-cecile added the X-Controversial There is active debate or serious implications around merging this PR label Feb 13, 2023
@alice-i-cecile alice-i-cecile removed this from the 0.10 milestone Feb 13, 2023
@alice-i-cecile
Copy link
Member

This is relatively complex, and we haven't reached consensus on the design. Removing from the 0.10 milestone.

@shanecelis
Copy link
Contributor

I thought I wanted Released too, but I was convinced that Released is a transition not a state by @Shatur. I added a longer comment here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-UI Graphical user interfaces, styles, layouts, and widgets C-Feature A new feature, making something new possible X-Controversial There is active debate or serious implications around merging this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for detecting release of a button
3 participants