core: add read only builder option to input state
This commit is contained in:
@@ -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
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user