feat(shortcuts): runtime configurable keyboard shortcuts
This commit is contained in:
parent
6f051b2456
commit
cf322fdb5e
47 changed files with 3305 additions and 416 deletions
|
|
@ -38,4 +38,21 @@ impl<'a, Message: 'static> Insert<'a, Message> {
|
|||
|
||||
self
|
||||
}
|
||||
|
||||
#[allow(clippy::return_self_not_must_use)]
|
||||
#[allow(clippy::must_use_candidate)]
|
||||
pub fn sub_page_with_id<P: AutoBind<Message>>(&mut self) -> Entity {
|
||||
let sub_page = self.model.register::<P>().id();
|
||||
|
||||
self.model.info[sub_page].parent = Some(self.id);
|
||||
|
||||
self.model
|
||||
.sub_pages
|
||||
.entry(self.id)
|
||||
.expect("parent page missing")
|
||||
.and_modify(|v| v.push(sub_page))
|
||||
.or_insert_with(|| vec![sub_page]);
|
||||
|
||||
sub_page
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,11 @@ pub trait Page<Message: 'static>: Downcast {
|
|||
None
|
||||
}
|
||||
|
||||
/// Set a custom page header
|
||||
fn header(&self) -> Option<Element<'_, Message>> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Display an inner app dialog for the page.
|
||||
fn dialog(&self) -> Option<Element<'_, Message>> {
|
||||
None
|
||||
|
|
@ -116,6 +121,7 @@ impl Info {
|
|||
#[macro_export]
|
||||
macro_rules! update {
|
||||
($binder:expr, $message:expr, $page:ty) => {{
|
||||
#[allow(unused_must_use)]
|
||||
if let Some(page) = $binder.page_mut::<$page>() {
|
||||
page.update($message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue