freya_components/native_router.rs
1use freya_core::prelude::*;
2use freya_router::prelude::RouterContext;
3
4pub trait NativeRouterExt {
5 /// Wire native back/forward mouse buttons to router navigation.
6 fn native_router(self) -> Self;
7}
8
9impl NativeRouterExt for Rect {
10 fn native_router(self) -> Self {
11 self.on_global_pointer_press(|e: Event<PointerEventData>| match e.button() {
12 Some(MouseButton::Back) => RouterContext::get().go_back(),
13 Some(MouseButton::Forward) => RouterContext::get().go_forward(),
14 _ => {}
15 })
16 }
17}