diff options
| author | 2025-02-13 05:19:32 +0100 | |
|---|---|---|
| committer | 2025-02-13 05:19:32 +0100 | |
| commit | f889008e21971b461ec7c54d9a7667a23f6ab35b (patch) | |
| tree | 91d9d34c87796da424104c46705e9f1aceb69f92 /core | |
| parent | 97f1db3783dca5a4f60a9f89668613de4dfe9edd (diff) | |
| parent | 89a4dc2ac2a751fdcae921997bb93a76f9b667f9 (diff) | |
| download | iced-f889008e21971b461ec7c54d9a7667a23f6ab35b.tar.gz iced-f889008e21971b461ec7c54d9a7667a23f6ab35b.tar.bz2 iced-f889008e21971b461ec7c54d9a7667a23f6ab35b.zip | |
Merge pull request #2793 from rhysd/issue-2792
Fix the initial candidate window position
Diffstat (limited to 'core')
| -rw-r--r-- | core/src/input_method.rs | 44 | ||||
| -rw-r--r-- | core/src/shell.rs | 2 | 
2 files changed, 14 insertions, 32 deletions
| diff --git a/core/src/input_method.rs b/core/src/input_method.rs index 9c83b083..cd8d459d 100644 --- a/core/src/input_method.rs +++ b/core/src/input_method.rs @@ -6,14 +6,10 @@ 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. +    /// Input method is disabled.      Disabled, -    /// Input methods are allowed, but not open yet. -    Allowed, -    /// Input method is open. -    Open { +    /// Input method is enabled. +    Enabled {          /// The position at which the input method dialog should be placed.          position: Point,          /// The [`Purpose`] of the input method. @@ -91,13 +87,13 @@ impl InputMethod {      /// # use iced_core::input_method::{InputMethod, Purpose, Preedit};      /// # use iced_core::Point;      /// -    /// let open = InputMethod::Open { +    /// let open = InputMethod::Enabled {      ///     position: Point::ORIGIN,      ///     purpose: Purpose::Normal,      ///     preedit: Some(Preedit { content: "1".to_owned(), selection: None, text_size: None }),      /// };      /// -    /// let open_2 = InputMethod::Open { +    /// let open_2 = InputMethod::Enabled {      ///     position: Point::ORIGIN,      ///     purpose: Purpose::Secure,      ///     preedit: Some(Preedit { content: "2".to_owned(), selection: None, text_size: None }), @@ -105,12 +101,6 @@ impl InputMethod {      ///      /// let mut ime = InputMethod::Disabled;      /// -    /// ime.merge(&InputMethod::<String>::Allowed); -    /// assert_eq!(ime, InputMethod::Allowed); -    /// -    /// ime.merge(&InputMethod::<String>::Disabled); -    /// assert_eq!(ime, InputMethod::Allowed); -    ///      /// ime.merge(&open);      /// assert_eq!(ime, open);      /// @@ -118,22 +108,16 @@ impl InputMethod {      /// assert_eq!(ime, open);      /// ```      pub fn merge<T: AsRef<str>>(&mut self, other: &InputMethod<T>) { -        match (&self, other) { -            (InputMethod::Open { .. }, _) -            | ( -                InputMethod::Allowed, -                InputMethod::None | InputMethod::Disabled, -            ) -            | (InputMethod::Disabled, InputMethod::None) => {} -            _ => { -                *self = other.to_owned(); -            } +        if let InputMethod::Enabled { .. } = self { +            return;          } + +        *self = other.to_owned();      }      /// Returns true if the [`InputMethod`] is open. -    pub fn is_open(&self) -> bool { -        matches!(self, Self::Open { .. }) +    pub fn is_enabled(&self) -> bool { +        matches!(self, Self::Enabled { .. })      }  } @@ -144,14 +128,12 @@ impl<T> InputMethod<T> {          T: AsRef<str>,      {          match self { -            Self::None => InputMethod::None,              Self::Disabled => InputMethod::Disabled, -            Self::Allowed => InputMethod::Allowed, -            Self::Open { +            Self::Enabled {                  position,                  purpose,                  preedit, -            } => InputMethod::Open { +            } => InputMethod::Enabled {                  position: *position,                  purpose: *purpose,                  preedit: preedit.as_ref().map(Preedit::to_owned), diff --git a/core/src/shell.rs b/core/src/shell.rs index 509e3822..56250e2e 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::None, +            input_method: InputMethod::Disabled,          }      } | 
