core: add read only builder option to input state

This commit is contained in:
2026-11-12 08:55:05 +07:00
parent ccd8997801
commit 9678a7676f
2 changed files with 18 additions and 0 deletions
+9
View File
@@ -535,6 +535,7 @@ pub struct InputStateBuilder {
text: String,
multiline: bool,
password: bool,
read_only: bool,
}
impl InputStateBuilder {
@@ -559,12 +560,19 @@ impl InputStateBuilder {
self
}
/// Refuses user edits, focus, movement, selection and copy stay.
pub fn read_only(mut self) -> Self {
self.read_only = true;
self
}
/// Creates the state entity.
pub fn build(self, cx: &mut App) -> Entity<InputState> {
let InputStateBuilder {
text,
multiline,
password,
read_only,
} = self;
cx.new(|cx| {
@@ -574,6 +582,7 @@ impl InputStateBuilder {
state.anchor = state.cursor;
state.multiline = multiline;
state.password = password;
state.read_only = read_only;
state
})
}