Using Chooser and ActorChooser

This tutorial covers building selectable lists with the generic Chooser<T> and the party‑focused ActorChooser wrapper.

What you’ll learn

  • Render a vertical list navigated with UP/DOWN and confirmed with OK.

  • Highlight the selected row and handle selection/highlight events.

  • Build a party selector using ActorChooser with PartyMemberFull/PartyMemberCompact.

Chooser<T> at a glance

File: menus/src/components/Chooser.tsx

Chooser – string list

Props

  • items: T[]

  • children: (item: T, selected: boolean) => React.ReactNode

  • hasFocus: boolean

  • onItemSelected?(item: T, index: number)

  • onItemHighlighted?(item: T, index: number)

  • resetSelection?: boolean

Input

  • Uses InputContext internally and listens to UP, DOWN, and OK when hasFocus is true.

Example: simple string menu

ActorChooser

File: menus/src/components/ActorChooser.tsx

ActorChooser – full cards

Props

  • Inherits BaseMenuScreenProps (pageData, isTestMenu, hasFocus)

  • onActorSelected(actor: any)

  • useFullView?: boolean — toggles between PartyMemberFull and PartyMemberCompact

Behavior

  • Reads party members from props.pageData.runtime.gameParty.members().

  • Internally uses Chooser and renders either full or compact member cards.

Example: pick a party member

Tips

  • Pass hasFocus={true} only when the chooser should accept input (e.g., no modal on top).

  • Use resetSelection when swapping data sets to ensure the selection returns to 0.

  • ActorChooser rows are wrapped in mobx-react-lite observers, so UI reacts to live stat changes.

See also

Last updated