Skip to content

Allow checking whether a TextEditor is focused#2386

Merged
hecrj merged 1 commit into
iced-rs:masterfrom
mtkennerly:feature/check-text-editor-focus
Apr 17, 2024
Merged

Allow checking whether a TextEditor is focused#2386
hecrj merged 1 commit into
iced-rs:masterfrom
mtkennerly:feature/check-text-editor-focus

Conversation

@mtkennerly

Copy link
Copy Markdown
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

@hecrj hecrj left a comment

Copy link
Copy Markdown
Member

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
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