Are you an LLM? You can read better optimized documentation at /zombsWiki/architecture/engine/main/ui/components/UiToolbarItem.md for this page in Markdown format
UiToolbarItem
The UiToolbarItem class represents a single inventory item button in the toolbar. It displays the item's current tier via data-tier and toggles an is-empty state when the item is not owned. Clicking equips or uses the item.
UiToolbarItem private
Extends UiComponent.
Properties
| Name | Type | Description |
|---|---|---|
ui | Ui | Current Ui instance. Inherited from UiComponent. |
componentElem | HTMLElement | The .hud-toolbar-item anchor element with data-item attribute. |
itemId | string | The item schema ID. |
tooltip | UiTooltip | The tooltip instance for this button. |
Methods
constructor()
ts
function constructor(ui: Ui, itemId: string): voidCreates the item button, attaches a UiTooltip, binds mousedown/mouseup listeners, and registers for itemSchemaUpdate and inventoryUpdate events.
update()
ts
function update(): voidSets data-tier from inventory data (defaults to '1') and toggles the is-empty class based on whether the item is owned.
onTooltipCreate()
ts
function onTooltipCreate(): stringReturns tooltip HTML showing the item name, tier, and description.
onMouseDown()
ts
function onMouseDown(event: MouseEvent): voidStops event propagation.
onMouseUp()
ts
function onMouseUp(event: MouseEvent): voidStops event propagation and emits equipOrUseItem with the item ID and tier.
onItemSchemaUpdate()
ts
function onItemSchemaUpdate(): voidCalls update().
onInventoryUpdate()
ts
function onInventoryUpdate(): voidCalls update().