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

do not check for focus until cursor position has been set #1070

Merged
merged 2 commits into from
Dec 23, 2020

Conversation

mockersf
Copy link
Member

fixes #1036

how to see the issue: in example button.rs, comment this line, the button will be displayed in the bottom left corner with "Hover" state

this is because the mouse position in the local resource for the ui_focus_system is created with (0,0).

This PR wraps the cursor_position in the local state in an option, and do not compute focus if this option is None

@Moxinilian Moxinilian added C-Bug An unexpected or incorrect behavior A-UI Graphical user interfaces, styles, layouts, and widgets labels Dec 15, 2020
@cart
Copy link
Member

cart commented Dec 22, 2020

I dig this. Now that we store the cursor_position in the window, I think it makes sense to simplify the focus impl. I just pushed a commit that does that.

@cart
Copy link
Member

cart commented Dec 22, 2020

(feel free to comment on that though, we can always drop the commit)

}
let cursor_position = if let Some(cursor_position) = windows
.get_primary()
.and_then(|window| window.cursor_position())
Copy link
Member Author

Choose a reason for hiding this comment

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

will that work when having multiple windows? anyway did it even work before with multiple windows?

Copy link
Member

Choose a reason for hiding this comment

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

It didn't filter according to WindowId, so it would have supported multiple windows for focus events. But the rest of the UI system doesn't support multiple windows, so it doesn't really matter. If/when that ever gets built we can use the same approach here.

@cart cart merged commit 09c15ea into bevyengine:master Dec 23, 2020
@mockersf mockersf deleted the focus-start-position branch April 27, 2021 23:51
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-Bug An unexpected or incorrect behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ButtonBundle starts up with Hovered Interaction.
3 participants