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

Allow checking whether a TextEditor is focused #2386

Merged
merged 1 commit into from
Apr 17, 2024

Conversation

mtkennerly
Copy link
Contributor

My use case is that I have a widget for wrapping TextInput and handling undo/redo shortcuts if the widget is focused. I'd like to do the same for TextEditor, but it doesn't currently expose a way to check for focus. I added an is_focused method, like the one that TextInput has.

I tested both of these checks with these changes:

  • tree.state.downcast_ref::<iced::widget::text_editor::State<iced::advanced::text::highlighter::PlainText>>().is_focused()
  • tree.state.downcast_ref::<iced::widget::text_editor::State<iced::highlighter::Highlighter>>().is_focused()

@hecrj hecrj added this to the 0.13 milestone Apr 17, 2024
@hecrj hecrj added feature New feature or request text widget addition labels Apr 17, 2024
Copy link
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Thanks! We should eventually consider implementing operation::Focusable and operation::TextInput for it too.

@hecrj hecrj merged commit ba705d6 into iced-rs:master Apr 17, 2024
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants