input: Change InputState::disabled to as builder method. (#898)
## Break Changes - The `disabled` method now is for builder method, and `is_disabled` for get state. ```diff - pub fn disabled(mut self) -> bool + pub fn is_disabled(&self) -> bool + pub fn disabled(mut self, disabled: bool) -> Self ```
This commit is contained in:
parent
1c11b5fb55
commit
0a9de15d79
2 changed files with 18 additions and 8 deletions
|
|
@ -665,12 +665,27 @@ impl InputState {
|
|||
self.replace_text_in_range(Some(range), &text, window, cx);
|
||||
}
|
||||
|
||||
/// Set with disabled mode.
|
||||
///
|
||||
/// See also: [`Self::set_disabled`], [`Self::is_disabled`].
|
||||
pub fn disabled(mut self, disabled: bool) -> Self {
|
||||
self.disabled = disabled;
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the disabled state of the input field.
|
||||
///
|
||||
/// See also: [`Self::disabled`], [`Self::is_disabled`].
|
||||
pub fn set_disabled(&mut self, disabled: bool, _: &mut Window, cx: &mut Context<Self>) {
|
||||
self.disabled = disabled;
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
/// Return is the input field is disabled.
|
||||
pub fn is_disabled(&self) -> bool {
|
||||
self.disabled
|
||||
}
|
||||
|
||||
/// Set with password masked state.
|
||||
pub fn masked(mut self, masked: bool) -> Self {
|
||||
self.masked = masked;
|
||||
|
|
@ -734,10 +749,6 @@ impl InputState {
|
|||
self.mask_pattern.unmask(&self.text).into()
|
||||
}
|
||||
|
||||
pub fn disabled(&self) -> bool {
|
||||
self.disabled
|
||||
}
|
||||
|
||||
/// Focus the input field.
|
||||
pub fn focus(&self, window: &mut Window, _: &mut Context<Self>) {
|
||||
self.focus_handle.focus(window);
|
||||
|
|
|
|||
|
|
@ -67,11 +67,10 @@ impl DivInspector {
|
|||
};
|
||||
|
||||
let input_state = cx.new(|cx| {
|
||||
let mut state = InputState::new(window, cx)
|
||||
InputState::new(window, cx)
|
||||
.code_editor(Some("json"), theme)
|
||||
.line_number(false);
|
||||
state.set_disabled(true, window, cx);
|
||||
state
|
||||
.line_number(false)
|
||||
.disabled(true)
|
||||
});
|
||||
|
||||
Self {
|
||||
|
|
|
|||
Loading…
Reference in a new issue