Skip to content

Conversation

@BrooksPatton
Copy link

I added a QueryFilter option by_id which takes in a WidgetId. This is helpful especially if we want to focus on our own component from our component.

Example, we check if we've been clicked on, and if so focus on ourselves.

I didn't see any automated tests in this section so I didn't add any.

@JustusFluegel
Copy link

Quick summary i wrote on @BrooksPatton 's stream for this pr, just posting it here for completeness :)

Summary

  • Adds DefferedComponents::by_id(&mut self, WidgetId) -> QueryBuilder<'_> method
  • Adds QueryBuilder<'_>::by_id(self, WidgetId) -> Self method

In support of that

  • Adds Filter:Id(WidgetId) filter variant

Motivation

Some actions (e.g. focus) are only available for deferred components, an sometimes we wish to execute them on the current or a child component. As such the following pattern seems desirable:

let my_id = context.widget_id; 
// or
let my_id = children.components().by_name("...")....; 

context.components.by_id(my_id).focus()

@BrooksPatton
Copy link
Author

Thanks Justus!

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.

2 participants