Skip to main content

Navigator class

Namespace: Arlecchino.Navigation · Assembly: Arlecchino

Holds the screen being shown and the history behind it. Routes returned from handlers pass through here, and the view that leaves is disposed if it asked to be.

public class Navigator

Properties

MemberSummary
CanGoBackWhether there is somewhere to go back to.
CanGoForwardWhether a step back can be retraced.
CurrentCommandsCommands of the screen being shown, for the router and the palette.
CurrentHintsWhat the hints box should show: the keys of whatever holds the focus, then the screen's own hints or its commands. A key the focused element claims wins, so nothing is listed twice.
CurrentIsTypingWhether the screen being shown has something on it being typed into.
CurrentRouteThe route being shown.
CurrentUsesLayoutWhether the screen being shown wants the layout drawn around it.

Methods

MemberSummary
Apply(ViewRoute)Goes to a route. Ignores ViewRoute.None and the route already shown; anything else pushes the current one onto the back stack and drops the forward stack.
Back()Goes back one step in the history.
Draw()Draws the current screen. Called once per frame.
Forward()Retraces a step that was gone back from.
Handle(KeyPress)Passes a key to the current screen and applies the route it returns.
HandleMouse(MouseEvent)Passes a mouse event to the current screen and applies the route it returns.
HandlePaste(string)Passes pasted text to the current screen and applies the route it returns.
Reload()Builds the current screen again from scratch, losing its per-screen state.

Properties in detail

CanGoBack

public bool CanGoBack { get; }

Whether there is somewhere to go back to.

Type bool

CanGoForward

public bool CanGoForward { get; }

Whether a step back can be retraced.

Type bool

CurrentCommands

public IReadOnlyList<ViewCommand> CurrentCommands { get; }

Commands of the screen being shown, for the router and the palette.

Type IReadOnlyList<T><ViewCommand>

CurrentHints

public ValueTuple<string, string>[] CurrentHints { get; }

What the hints box should show: the keys of whatever holds the focus, then the screen's own hints or its commands. A key the focused element claims wins, so nothing is listed twice.

Type ValueTuple<T1, T2><string, string>[]

CurrentIsTyping

public bool CurrentIsTyping { get; }

Whether the screen being shown has something on it being typed into.

Type bool

CurrentRoute

public ViewRoute CurrentRoute { get; }

The route being shown.

Type ViewRoute

CurrentUsesLayout

public bool CurrentUsesLayout { get; }

Whether the screen being shown wants the layout drawn around it.

Type bool

Methods in detail

Apply(ViewRoute)

public void Apply(ViewRoute route);

Goes to a route. Ignores ViewRoute.None and the route already shown; anything else pushes the current one onto the back stack and drops the forward stack.

Parameters

NameTypeDescription
routeViewRouteWhere to go.

Back()

public bool Back();

Goes back one step in the history.

Returns boolfalse when there was nothing to go back to.

Draw()

public void Draw();

Draws the current screen. Called once per frame.

Forward()

public bool Forward();

Retraces a step that was gone back from.

Returns boolfalse when there was nothing to retrace.

Handle(KeyPress)

public void Handle(KeyPress key);

Passes a key to the current screen and applies the route it returns.

Parameters

NameTypeDescription
keyKeyPressThe key that was pressed.

HandleMouse(MouseEvent)

public void HandleMouse(MouseEvent mouse);

Passes a mouse event to the current screen and applies the route it returns.

Parameters

NameTypeDescription
mouseMouseEventThe event, in frame coordinates.

HandlePaste(string)

public void HandlePaste(string text);

Passes pasted text to the current screen and applies the route it returns.

Parameters

NameTypeDescription
textstringWhat was pasted.

Reload()

public void Reload();

Builds the current screen again from scratch, losing its per-screen state.