Skip to content

UI Actions and Selection

This page covers the action model used by collection widgets and the interfaces used for selection visuals.

UI Action System

Collection widgets support generic item-level UI actions.

The action system is intentionally data-source agnostic, so UI elements can send requests without needing to know whether the backing data came from a table, a grid, or another host type.

IDataUIActionHost

Widgets that can process item actions implement IDataUIActionHost.

bool TryHandleAction(in DataUIActionRequest request);

Examples include:

  • DataTableWidget
  • DataGridWidget (planned)

DataUIActionRequest

DataUIActionRequest is the generic request packet sent by UI elements.

It contains:

  • ItemId
  • ItemKey
  • ActionType

Optional fields include:

  • IntArg
  • StringArg
  • Payload
  • Sender

The host decides how to interpret ItemId.

DataUIActionType

Common built-in actions include:

Selection:

  • Select
  • ToggleSelect

Modification:

  • Delete
  • MoveUp
  • MoveDown

Drag lifecycle:

  • BeginDrag
  • EndDrag
  • CancelDrag

Miscellaneous:

  • ContextMenu
  • Custom

IDataUISelectionVisual

IDataUISelectionVisual lets widgets control selection visuals without depending on a specific implementation.

void SetSelected(bool selected);   // may animate
void SyncSelected(bool selected);  // snap state for pooling or rebuild

DataItemSelection

DataItemSelection is the default MonoBehaviour implementation for selection visuals.

It supports:

  • Toggling a GameObject on and off
  • Driving an Animator bool parameter named Selected