Draft conversion::menu_message in iced_winit
... and wire it up to the runtime loop
This commit is contained in:
parent
f3b056a6fc
commit
6221adf2b1
3 changed files with 31 additions and 0 deletions
|
|
@ -306,6 +306,16 @@ async fn run_instance<A, E, C>(
|
||||||
// TODO: Handle animations!
|
// TODO: Handle animations!
|
||||||
// Maybe we can use `ControlFlow::WaitUntil` for this.
|
// Maybe we can use `ControlFlow::WaitUntil` for this.
|
||||||
}
|
}
|
||||||
|
event::Event::WindowEvent {
|
||||||
|
event: event::WindowEvent::MenuEntryActivated(entry_id),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if let Some(message) =
|
||||||
|
conversion::menu_message(state.menu(), entry_id)
|
||||||
|
{
|
||||||
|
messages.push(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
event::Event::WindowEvent {
|
event::Event::WindowEvent {
|
||||||
event: window_event,
|
event: window_event,
|
||||||
..
|
..
|
||||||
|
|
|
||||||
|
|
@ -386,6 +386,16 @@ async fn run_instance<A, E, C>(
|
||||||
// TODO: Handle animations!
|
// TODO: Handle animations!
|
||||||
// Maybe we can use `ControlFlow::WaitUntil` for this.
|
// Maybe we can use `ControlFlow::WaitUntil` for this.
|
||||||
}
|
}
|
||||||
|
event::Event::WindowEvent {
|
||||||
|
event: event::WindowEvent::MenuEntryActivated(entry_id),
|
||||||
|
..
|
||||||
|
} => {
|
||||||
|
if let Some(message) =
|
||||||
|
conversion::menu_message(state.menu(), entry_id)
|
||||||
|
{
|
||||||
|
messages.push(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
event::Event::WindowEvent {
|
event::Event::WindowEvent {
|
||||||
event: window_event,
|
event: window_event,
|
||||||
..
|
..
|
||||||
|
|
|
||||||
|
|
@ -215,6 +215,17 @@ pub fn menu<Message>(menu: &Menu<Message>) -> winit::window::Menu {
|
||||||
converted
|
converted
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Given a [`Menu`] and an identifier of a [`menu::Entry`], it returns the
|
||||||
|
/// `Message` that should be produced when that entry is activated.
|
||||||
|
pub fn menu_message<Message>(
|
||||||
|
_menu: &Menu<Message>,
|
||||||
|
id: isize,
|
||||||
|
) -> Option<Message> {
|
||||||
|
println!("Menu entry activated: {}", id);
|
||||||
|
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
/// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon.
|
/// Converts a `MouseCursor` from [`iced_native`] to a [`winit`] cursor icon.
|
||||||
///
|
///
|
||||||
/// [`winit`]: https://github.com/rust-windowing/winit
|
/// [`winit`]: https://github.com/rust-windowing/winit
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue