iced-rs / iced

A cross-platform GUI library for Rust, inspired by Elm
https://iced.rs
MIT License
26.33k stars 1.28k forks source link

`operation::focusable::is_focused` & `text_input::is_focused` #2812

Closed andymandias closed 1 month ago

andymandias commented 1 month ago

This PR consists of two additions:

  1. An is_focused function that produces an Operation that looks for a focusable widget by ID, and produces a bool that stores whether the widget is focused or not. This function was modeled after the existing find_focused, and for my purposes was a means to implement the second addition.
  2. An is_focused function that produces a Task that looks for a text_input widget by ID, and produces a bool with whether the widget is focused or not.

Originally I tried to use the find_focused Operation for text_input::is_focused, but I couldn't figure out how to make it work as desired when there is no currently focused widget (and find_focused produces Outcome::None).