32 lines
723 B
Rust
32 lines
723 B
Rust
use makepad_widgets::{Cx, Event, LiveId};
|
|
|
|
use crate::{
|
|
app::{App, AppAction},
|
|
RUNTIME,
|
|
};
|
|
|
|
pub fn handle_menu(cx: &mut Cx, event: &Event) {
|
|
match event {
|
|
Event::MacosMenuCommand(command) => {
|
|
if command == &LiveId::from_str("open_file") {
|
|
cx.action(AppAction::OpenFile);
|
|
}
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|
|
|
|
pub fn spawn_background(app: &mut App, event: &Event) {
|
|
match event {
|
|
Event::Draw(_) => {
|
|
// Render Task
|
|
let tasks = app.render_tasks.clone();
|
|
RUNTIME.spawn(async move {
|
|
let tasks = tasks.lock().await;
|
|
tasks.render().await;
|
|
});
|
|
}
|
|
_ => {}
|
|
}
|
|
}
|