Skip to main content

BackHandler

Struct BackHandler 

Source
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: RNode

The 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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.