Focusing widgets
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 9.7k
- Forks
- 565
- PR merge metrics
- No merged PRs in 30d
Description
Hello there, at the moment API for focusing widgets quite unfinished, I have been playing around with it.
I would like to suggest such an API: add two widgets FocusScope - serves as a scope for its descendants, restricting focus traversal to the scoped controls, it can be useful if I would like to add some overlay UI like alert and strict scope for this area. We could create FocusSope in the root by default.
Focus widget - is a control widget that can capture the focus and spread focus state to its descendants; in that case, all descendants can receive keyboard events. It's nice to have such a widget because we could handle all focus events like request next and previous focus only there. And we can wrap up focusable widgets, which could handle keyboard events to some other decorator widgets that also could be rendered differently depends on focus state.
I have already implemented the Focus widget and now working on the FocusScope widget; it's much trickier.
**Example:**
```rust
let input = Focus::new(
AccessorDecorator::new(
FocusDecorator::new(),
AccessorDecorator::new(
TextboxDecorator::new(),
TextBox::new()
.with_placeholder("Enter the command")
.fix_width(TEXT_BOX_WIDTH)
.lens(HelloState::name),
)
.padding(2.0),
),
);
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the existing focus API and the Focus, FocusScope, FocusDecorator, and AccessorDecorator entry points shown in the issue. Compare the implemented Focus behavior with the proposed descendant scoping and keyboard-event behavior. Done means the intended Focus and FocusScope semantics are defined and implemented consistently with the example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100