Add focus id to text editor

This commit is contained in:
Sosthène Guédon 2024-11-11 11:05:46 +01:00 committed by Ashley Wulber
parent 49b154c048
commit 46c745be2c
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820

View file

@ -63,6 +63,16 @@ pub use text::editor::{
Action, Cursor, Edit, Line, LineEnding, Motion, Position, Selection,
};
/// The identifier of a [`TextEditor`].
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Id(widget::Id);
impl From<widget::Id> for Id {
fn from(value: widget::Id) -> Self {
Id(value)
}
}
/// A multi-line text input.
///
/// # Example
@ -1096,6 +1106,13 @@ where
operation.focusable(self.id.as_ref(), layout.bounds(), state);
}
fn id(&self) -> Option<widget::Id> {
self.id.clone()
}
fn set_id(&mut self, id: widget::Id) {
self.id = Some(id);
}
}
impl<'a, Highlighter, Message, Theme, Renderer>