diff --git a/CHANGELOG.md b/CHANGELOG.md index e4557f69fb..6690c0adaa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `style` attribute for `Font`. [#2041](https://github.com/iced-rs/iced/pull/2041) - Texture filtering options for `Image`. [#1894](https://github.com/iced-rs/iced/pull/1894) - `default` and `shift_step` methods for `slider` widgets. [#2100](https://github.com/iced-rs/iced/pull/2100) +- `Custom` variant to `command::Action`. [#2146](https://github.com/iced-rs/iced/pull/2146) ### Changed - Enable WebGPU backend in `wgpu` by default instead of WebGL. [#2068](https://github.com/iced-rs/iced/pull/2068) @@ -101,6 +102,7 @@ Many thanks to... - @casperstorm - @cfrenette - @Davidster +- @Decodetalkers - @derezzedex - @dtzxporter - @GyulyVGC diff --git a/runtime/src/command/action.rs b/runtime/src/command/action.rs index cb0936df74..c9ffe801c4 100644 --- a/runtime/src/command/action.rs +++ b/runtime/src/command/action.rs @@ -1,11 +1,11 @@ use crate::clipboard; use crate::core::widget; use crate::font; +use crate::futures::MaybeSend; use crate::system; use crate::window; -use iced_futures::MaybeSend; - +use std::any::Any; use std::borrow::Cow; use std::fmt; @@ -43,6 +43,9 @@ pub enum Action { /// The message to produce when the font has been loaded. tagger: Box) -> T>, }, + + /// A custom action supported by a specific runtime. + Custom(Box), } impl Action { @@ -72,6 +75,7 @@ impl Action { bytes, tagger: Box::new(move |result| f(tagger(result))), }, + Self::Custom(custom) => Action::Custom(custom), } } } @@ -90,6 +94,7 @@ impl fmt::Debug for Action { Self::System(action) => write!(f, "Action::System({action:?})"), Self::Widget(_action) => write!(f, "Action::Widget"), Self::LoadFont { .. } => write!(f, "Action::LoadFont"), + Self::Custom(_) => write!(f, "Action::Custom"), } } } diff --git a/winit/src/application.rs b/winit/src/application.rs index 21a985e8b1..24c98d46dc 100644 --- a/winit/src/application.rs +++ b/winit/src/application.rs @@ -861,6 +861,9 @@ pub fn run_command( .send_event(tagger(Ok(()))) .expect("Send message to event loop"); } + command::Action::Custom(_) => { + log::warn!("Unsupported custom action in `iced_winit` shell"); + } } } } diff --git a/winit/src/multi_window.rs b/winit/src/multi_window.rs index 1c45ce37e0..662adf5b43 100644 --- a/winit/src/multi_window.rs +++ b/winit/src/multi_window.rs @@ -1127,6 +1127,9 @@ fn run_command( .send_event(tagger(Ok(()))) .expect("Send message to event loop"); } + command::Action::Custom(_) => { + log::warn!("Unsupported custom action in `iced_winit` shell"); + } } } }