summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar rhysd <lin90162@yahoo.co.jp>2025-02-06 09:57:01 +0900
committerLibravatar rhysd <lin90162@yahoo.co.jp>2025-02-06 09:57:01 +0900
commitcf851e133ad6aaedaf07b58c68e7c41d41ee151a (patch)
treef46a9317e23ebe32018dad80d0c2269e43515cca
parentfcdf53afdee9cd12bf2e01c5f6e572859b9a3f96 (diff)
downloadiced-cf851e133ad6aaedaf07b58c68e7c41d41ee151a.tar.gz
iced-cf851e133ad6aaedaf07b58c68e7c41d41ee151a.tar.bz2
iced-cf851e133ad6aaedaf07b58c68e7c41d41ee151a.zip
Do not pass text size to `Preedit::new`
-rw-r--r--core/src/input_method.rs7
-rw-r--r--widget/src/text_editor.rs4
-rw-r--r--widget/src/text_input.rs9
3 files changed, 12 insertions, 8 deletions
diff --git a/core/src/input_method.rs b/core/src/input_method.rs
index ab00b5af..9c83b083 100644
--- a/core/src/input_method.rs
+++ b/core/src/input_method.rs
@@ -40,14 +40,11 @@ pub struct Preedit<T = String> {
impl<T> Preedit<T> {
/// Creates a new empty [`Preedit`].
- pub fn new(text_size: Option<impl Into<Pixels>>) -> Self
+ pub fn new() -> Self
where
T: Default,
{
- Self {
- text_size: text_size.map(Into::into),
- ..Default::default()
- }
+ Self::default()
}
/// Turns a [`Preedit`] into its owned version.
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs
index df42d601..ac458951 100644
--- a/widget/src/text_editor.rs
+++ b/widget/src/text_editor.rs
@@ -754,7 +754,9 @@ where
Update::InputMethod(update) => match update {
Ime::Toggle(is_open) => {
state.preedit = is_open.then(|| {
- input_method::Preedit::new(self.text_size)
+ let mut preedit = input_method::Preedit::new();
+ preedit.text_size = self.text_size;
+ preedit
});
shell.request_redraw();
diff --git a/widget/src/text_input.rs b/widget/src/text_input.rs
index de957e14..6d317490 100644
--- a/widget/src/text_input.rs
+++ b/widget/src/text_input.rs
@@ -1261,8 +1261,13 @@ where
let state = state::<Renderer>(tree);
state.is_ime_open =
- matches!(event, input_method::Event::Opened)
- .then(|| input_method::Preedit::new(self.size));
+ matches!(event, input_method::Event::Opened).then(
+ || {
+ let mut preedit = input_method::Preedit::new();
+ preedit.text_size = self.size;
+ preedit
+ },
+ );
shell.request_redraw();
}