Skip to content

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>
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 you

You reach one through the controller:

i32 d = nav.depth(); // how many forms deep
UXNavItem* it = nav.itemAt(d - 1); // the top entry
u8* t = it.title; // "Detail"
UXView* v = it.content; // the view pushed with it

You rarely need the item itself. The controller exposes the same information directly, which reads better at a call site:

instead ofwrite
nav.itemAt(i).titlenav.titleAt(i)
nav.itemAt(i).contentnav.contentAt(i)
nav.itemAt(nav.depth()-1).titlenav.topTitle()
nav.itemAt(nav.depth()-1).contentnav.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.

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.

u8* title

What 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.

UXView* content

The 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).