diff options
author | 2025-02-02 21:06:50 +0100 | |
---|---|---|
committer | 2025-02-02 21:06:50 +0100 | |
commit | db990b77e4aa8d001c774703301342c951d6caaa (patch) | |
tree | 5fe6d046fa17c0a99438fbde7b8e748c8941afca | |
parent | ae10adda74320e8098bfeb401f12a278e1e7b3e2 (diff) | |
download | iced-db990b77e4aa8d001c774703301342c951d6caaa.tar.gz iced-db990b77e4aa8d001c774703301342c951d6caaa.tar.bz2 iced-db990b77e4aa8d001c774703301342c951d6caaa.zip |
Add neutral `None` variant to `InputMethod`
-rw-r--r-- | core/src/input_method.rs | 13 | ||||
-rw-r--r-- | core/src/shell.rs | 2 | ||||
-rw-r--r-- | runtime/src/user_interface.rs | 2 | ||||
-rw-r--r-- | winit/src/program/window_manager.rs | 11 |
4 files changed, 19 insertions, 9 deletions
diff --git a/core/src/input_method.rs b/core/src/input_method.rs index c293582d..b25f29aa 100644 --- a/core/src/input_method.rs +++ b/core/src/input_method.rs @@ -6,6 +6,8 @@ use std::ops::Range; /// The input method strategy of a widget. #[derive(Debug, Clone, PartialEq)] pub enum InputMethod<T = String> { + /// No input method strategy has been specified. + None, /// No input method is allowed. Disabled, /// Input methods are allowed, but not open yet. @@ -73,7 +75,7 @@ impl InputMethod { /// ``` pub fn merge<T: AsRef<str>>(&mut self, other: &InputMethod<T>) { match other { - InputMethod::Disabled => {} + InputMethod::None => {} InputMethod::Open { position, purpose, @@ -88,10 +90,15 @@ impl InputMethod { .map(str::to_owned), }; } - InputMethod::Allowed if matches!(self, Self::Disabled) => { + InputMethod::Allowed + if matches!(self, Self::None | Self::Disabled) => + { *self = Self::Allowed; } - InputMethod::Allowed => {} + InputMethod::Disabled if matches!(self, Self::None) => { + *self = Self::Disabled; + } + _ => {} } } } diff --git a/core/src/shell.rs b/core/src/shell.rs index e87d1696..d01233c7 100644 --- a/core/src/shell.rs +++ b/core/src/shell.rs @@ -27,7 +27,7 @@ impl<'a, Message> Shell<'a, Message> { redraw_request: window::RedrawRequest::Wait, is_layout_invalid: false, are_widgets_invalid: false, - input_method: InputMethod::Disabled, + input_method: InputMethod::None, } } diff --git a/runtime/src/user_interface.rs b/runtime/src/user_interface.rs index 59e497c5..4bb7bba7 100644 --- a/runtime/src/user_interface.rs +++ b/runtime/src/user_interface.rs @@ -189,7 +189,7 @@ where let mut outdated = false; let mut redraw_request = window::RedrawRequest::Wait; - let mut input_method = InputMethod::Disabled; + let mut input_method = InputMethod::None; let mut manual_overlay = ManuallyDrop::new( self.root diff --git a/winit/src/program/window_manager.rs b/winit/src/program/window_manager.rs index cd49a8b4..32faa059 100644 --- a/winit/src/program/window_manager.rs +++ b/winit/src/program/window_manager.rs @@ -203,10 +203,13 @@ where } pub fn request_input_method(&mut self, input_method: InputMethod) { - self.raw.set_ime_allowed(match input_method { - InputMethod::Disabled => false, - InputMethod::Allowed | InputMethod::Open { .. } => true, - }); + match input_method { + InputMethod::None => {} + InputMethod::Disabled => self.raw.set_ime_allowed(false), + InputMethod::Allowed | InputMethod::Open { .. } => { + self.raw.set_ime_allowed(true) + } + } if let InputMethod::Open { position, |