pub struct BackHandler {
pub node: RNode,
pub layer: Box<dyn Fn() -> u64>,
pub active: Box<dyn Fn() -> bool>,
pub enabled: Box<dyn Fn() -> bool>,
pub run: Box<dyn Fn()>,
}Expand description
An app-level Back handler: Jetpack Compose’s BackHandler(enabled) { … }
(docs/navigation.md “Handling the system Back”). Registered with register_back_handler
by Decorate::on_system_back; removed with unregister_nav.
A handler is the last thing a back reaches. Every navigation surface answers first (a
presented cover closes, a pushed page pops, a guard decides), and only a back none of them
takes runs a handler, in place of the platform’s default (leaving the app). Among handlers
that are on screen and enabled, the one in the topmost cover wins, then the one nested most
deeply in the piece tree (the most ancestors above Self::node), then the most recently
registered.
Fields§
§node: RNodeThe node the handler’s piece is built under. Its depth in the tree, read when a back arrives rather than at registration (a document page can move to a window of its own), is what makes an inner handler win over an outer one, whichever mounted first.
layer: Box<dyn Fn() -> u64>Presentation order of the containing cover, like NavController::layer.
active: Box<dyn Fn() -> bool>Whether the handler is on screen, like NavController::active: false inside a resident
page its host is not showing.
enabled: Box<dyn Fn() -> bool>The app’s condition: whether the handler wants the back right now. Read untracked; the
caller re-runs sync_system_back when it changes.
run: Box<dyn Fn()>What a back the handler takes does.
Auto Trait Implementations§
impl !RefUnwindSafe for BackHandler
impl !Send for BackHandler
impl !Sync for BackHandler
impl !UnwindSafe for BackHandler
impl Forget for BackHandler
impl Freeze for BackHandler
impl Move for BackHandler
impl Unpin for BackHandler
impl UnsafeUnpin for BackHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more