UXNavItem
UXNavItem is one entry on a
UXNavigationController’s stack:
a title and the content view that form shows. The controller makes
them; you normally read them rather than construct them.
#use <UXKit>Overview
Section titled “Overview”class UXNavItem : Object { u8* title; // what the bar shows for this form UXView* content; // the form itself}The class has two fields and no behaviour. The navigation stack is a pure model (push, pop, depth, top) that can be exercised with no window and no driver, which works because the entries on the stack are inert.
You get one by pushing a form:
UXNavigationController* nav = new UXNavigationController();UXView* detail = new UXView();nav.push((u8*)"Detail", detail); // makes the UXNavItem for youYou reach one through the controller:
i32 d = nav.depth(); // how many forms deepUXNavItem* it = nav.itemAt(d - 1); // the top entryu8* t = it.title; // "Detail"UXView* v = it.content; // the view pushed with itReading the stack without UXNavItem
Section titled “Reading the stack without UXNavItem”You rarely need the item itself. The controller exposes the same information directly, which reads better at a call site:
| instead of | write |
|---|---|
nav.itemAt(i).title | nav.titleAt(i) |
nav.itemAt(i).content | nav.contentAt(i) |
nav.itemAt(nav.depth()-1).title | nav.topTitle() |
nav.itemAt(nav.depth()-1).content | nav.topContent() |
Those methods are built on UXNavItem. The class is public so that code walking
the whole stack, such as a breadcrumb or a restore-state pass, can hold an entry
instead of a pair of parallel indices.
Lifetime
Section titled “Lifetime”The controller owns its items strongly, in push order. A
pop removes the entry from the
stack but leaves the content view attached and hidden, so pushing the same
form again re-reveals it instead of rebuilding it. The item is freed; the view
it named is not.
Fields
Section titled “Fields”u8* titleWhat the navigation bar shows while this form is on top, and what the back
affordance of the form above it shows.
backTitle returns the title of
the entry under the top, because back returns to that entry.
content
Section titled “content”UXView* contentThe form’s view. The controller shows only the top one. On first push, if the
view is not already in a tree, the controller adds it as a subview at
contentFrame (the bounds minus
the navigation bar).
See also
Section titled “See also”UXNavigationController: the stack that owns these, and the delegate that reports forms appearing and leavingUXView: whatcontentis