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

Implement update_focus pass #538

Merged
merged 4 commits into from
Sep 12, 2024
Merged

Conversation

PoignardAzur
Copy link
Contributor

@PoignardAzur PoignardAzur commented Aug 24, 2024

Make Textbox Widget tab-focusable.

This is part of the Pass Specification RFC: linebender/rfcs#7

@PoignardAzur PoignardAzur force-pushed the implement_pass_spec_update_focus2 branch from 25a3962 to cc7c698 Compare August 25, 2024 09:24
if handled == Handled::No
&& key.physical_key == PhysicalKey::Code(KeyCode::Tab)
&& key.state == ElementState::Pressed
{
if !mods.shift_key() {
root.state.next_focused_widget = root.widget_from_focus_chain(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Future PR, but not a big fan of this boolean arg here, would be nicer to have Focus::Next Focus::Prev or something instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that part of the code is due for a refactor.

Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

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

Seems to work correctly, as far as I can see.

@@ -357,6 +349,9 @@ pub enum StatusChange {
///
/// [`EventCtx::is_focused`]: crate::EventCtx::is_focused
FocusChanged(bool),

/// Called when a widget becomes or no longer is parent of a focused widget.
HasFocusChanged(bool),
Copy link
Member

Choose a reason for hiding this comment

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

I think

    ChildFocusChanged(bool),

would be a better name, because HasFocusedChanged could also be read as "my focus has changed" - indeed, that's how I read it originally.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

masonry/src/render_root.rs Outdated Show resolved Hide resolved
@PoignardAzur PoignardAzur force-pushed the implement_pass_spec_update_focus2 branch from d88da11 to ddda94d Compare September 12, 2024 11:25
@PoignardAzur PoignardAzur added this pull request to the merge queue Sep 12, 2024
Merged via the queue into main with commit 4746766 Sep 12, 2024
17 checks passed
@PoignardAzur PoignardAzur deleted the implement_pass_spec_update_focus2 branch September 12, 2024 11:34
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