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

Focus-chain update #1724

Merged
merged 8 commits into from
Apr 19, 2021
Merged

Focus-chain update #1724

merged 8 commits into from
Apr 19, 2021

Conversation

xarvic
Copy link
Collaborator

@xarvic xarvic commented Apr 17, 2021

This is a fix of the part of #1716 @cmyr and i agreed on:

  • should_propagate_to_hidden() now returns false for Lifecycle::BuildFocusChain
  • Lifecycle::BuildFocusChain requests a a resign of focus if state.has_focus is set but neither one of its hidden children nor it self has focus.

The other point: What should happen if try to focus a WidgetID which is not allowed to recieve focus like ctx.set_focus(WidgetID::new()) or focusing a hidden widget is not addressed here.

@xarvic xarvic changed the title Focus chain update Focus-chain update Apr 17, 2021
@xarvic xarvic added the S-needs-review waits for review label Apr 17, 2021
@xarvic xarvic requested a review from cmyr April 17, 2021 15:54
Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

I'm a bit confused here, and will need to take a second look (or maybe we should have a quick chat about it) I'm having a slow time remembering the context for this. In any case, one question inline.

druid/src/core.rs Outdated Show resolved Hide resolved
// currently focused is not part of the functional tree anymore
// (Lifecycle::BuildFocusChain.should_propagate_to_hidden() is false!) and should
// resign the focus.
if had_focus && !self.state.has_focus {
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused; we haven't done merge_up yet, so how would has_focus have changed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The merge_up of our children happened already in line 1058 / 1062. If someone hides a focused widget and then calls children_changed(), we clear has_focus in BuildFocusChain if has_clear is not set after the calls in 1058 and 1062 we know, that the focused widget is not reachable

Copy link
Member

@cmyr cmyr left a comment

Choose a reason for hiding this comment

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

Okay, that explanation works for me, thanks!

@xarvic xarvic merged commit 452328c into linebender:master Apr 19, 2021
@xarvic xarvic deleted the focus-chain-update branch April 19, 2021 18:05
@maan2003 maan2003 removed the S-needs-review waits for review label May 3, 2021
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.

3 participants