diff options
author | 2025-02-03 03:22:10 +0100 | |
---|---|---|
committer | 2025-02-04 01:26:59 +0100 | |
commit | afef368d8a920c7702048d3b1604b2046fe46ff8 (patch) | |
tree | 956ce409f5969cfd6b163796f141213c6235b805 /widget/src/text_editor.rs | |
parent | 1b01d6718bf0c6b652a3256df51727c3e72fdd9e (diff) | |
download | iced-afef368d8a920c7702048d3b1604b2046fe46ff8.tar.gz iced-afef368d8a920c7702048d3b1604b2046fe46ff8.tar.bz2 iced-afef368d8a920c7702048d3b1604b2046fe46ff8.zip |
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, }; |