diff options
author | 2025-02-04 01:38:24 +0100 | |
---|---|---|
committer | 2025-02-04 01:38:24 +0100 | |
commit | 782b96b52f59dcde75bfa9d4affc8852e635e781 (patch) | |
tree | bb8b73b57c0c9b3a1677d8ba199dbed5e20eaac5 /widget/src/text_editor.rs | |
parent | 3f509c6d0e8aeeeb69b384df0665cbb7e6b6c663 (diff) | |
parent | afef368d8a920c7702048d3b1604b2046fe46ff8 (diff) | |
download | iced-782b96b52f59dcde75bfa9d4affc8852e635e781.tar.gz iced-782b96b52f59dcde75bfa9d4affc8852e635e781.tar.bz2 iced-782b96b52f59dcde75bfa9d4affc8852e635e781.zip |
Merge pull request #2781 from iced-rs/event-by-reference
Take `Event` by reference in `Widget::update`
Diffstat (limited to 'widget/src/text_editor.rs')
-rw-r--r-- | widget/src/text_editor.rs | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/widget/src/text_editor.rs b/widget/src/text_editor.rs index cfdf6b5d..e685256b 100644 --- a/widget/src/text_editor.rs +++ b/widget/src/text_editor.rs @@ -651,7 +651,7 @@ where fn update( &mut self, tree: &mut widget::Tree, - event: Event, + event: &Event, layout: Layout<'_>, cursor: mouse::Cursor, renderer: &Renderer, @@ -686,17 +686,18 @@ where Event::Window(window::Event::RedrawRequested(now)) => { if let Some(focus) = &mut state.focus { if focus.is_window_focused { - focus.now = now; + focus.now = *now; let millis_until_redraw = Focus::CURSOR_BLINK_INTERVAL_MILLIS - - (now - focus.updated_at).as_millis() + - (focus.now - focus.updated_at).as_millis() % Focus::CURSOR_BLINK_INTERVAL_MILLIS; shell.request_redraw_at( - now + Duration::from_millis( - millis_until_redraw as u64, - ), + focus.now + + Duration::from_millis( + millis_until_redraw as u64, + ), ); } } @@ -1216,7 +1217,7 @@ enum Ime { impl<Message> Update<Message> { fn from_event<H: Highlighter>( - event: Event, + event: &Event, state: &State<H>, bounds: Rectangle, padding: Padding, @@ -1284,14 +1285,14 @@ impl<Message> Update<Message> { if state.focus.is_some() => { Some(Update::InputMethod(Ime::Preedit { - content, - selection, + content: content.clone(), + selection: selection.clone(), })) } input_method::Event::Commit(content) if state.focus.is_some() => { - Some(Update::InputMethod(Ime::Commit(content))) + Some(Update::InputMethod(Ime::Commit(content.clone()))) } _ => None, }, @@ -1310,9 +1311,9 @@ impl<Message> Update<Message> { }; let key_press = KeyPress { - key, - modifiers, - text, + key: key.clone(), + modifiers: *modifiers, + text: text.clone(), status, }; |