Skip to content

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

NameTypeDescription
uiUiCurrent Ui instance. Inherited from UiComponent.
componentElemHTMLElementThe .hud-toolbar-item anchor element with data-item attribute.
itemIdstringThe item schema ID.
tooltipUiTooltipThe tooltip instance for this button.

Methods

constructor()

ts
function constructor(ui: Ui, itemId: string): void

Creates the item button, attaches a UiTooltip, binds mousedown/mouseup listeners, and registers for itemSchemaUpdate and inventoryUpdate events.

update()

ts
function update(): void

Sets 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(): string

Returns tooltip HTML showing the item name, tier, and description.

onMouseDown()

ts
function onMouseDown(event: MouseEvent): void

Stops event propagation.

onMouseUp()

ts
function onMouseUp(event: MouseEvent): void

Stops event propagation and emits equipOrUseItem with the item ID and tier.

onItemSchemaUpdate()

ts
function onItemSchemaUpdate(): void

Calls update().

onInventoryUpdate()

ts
function onInventoryUpdate(): void

Calls update().