Item Slot Element

🗃️ ItemSlotElement Class

Any-purpose item stack UI element with drag, drop, and context‐menu support.

Namespace: Esper.Inventool.UI Access: public Type: class Inherits: DraggableElement Attributes: [UxmlElement]


📦 Fields

Access
Field
Type
Description

public

acceptedItemType

ItemType

Only allow this item type (null = any).

public

acceptedEnchantmentMode

ItemType.EnchantmentMode

Obsolete filter for enchantment mode.

public

canAccept

Func<ItemStack,bool>

Custom predicate to allow/disallow item stacks.

public

containerElement

VisualElement

Wrapper for icon styling and cropping.

public

iconElement

VisualElement

Displays the item’s sprite.

public

amountLabel

Label

Shows stack count when showAmount is true.

public

onItemUpdated

UnityEvent

Invoked whenever the slot’s ItemStack changes.

public

actionMenuOptions

List<ActionMenuOption>

Configurable right-click menu actions.

protected

dragElement

VisualElement

Floating UI during drag.

protected

dragIconElement

VisualElement

Icon inside the drag proxy.

public

useItemRestrictions

bool

Enforce canAccept and acceptedItemType filters.

public

showAmount

bool

Toggle visibility of amountLabel.


🔍 Properties

Access
Property
Type
Description

public

ItemStack

ItemStack

Currently assigned item stack (get only).

public

HasItem

bool

True if ItemStack is non-null and valid.


🔧 Constructors

Access
Signature
Description

public

ItemSlotElement()

Wire drag callbacks, build container/icon/label elements, and add default “Remove” action.


🧰 Methods

Access
Method
Returns
Description

protected virtual

OnPointerEnter(PointerEnterEvent e)

void

Open hover details for this slot.

protected virtual

OnPointerLeave(PointerLeaveEvent e)

void

Close hover details.

protected virtual

OnClick()

void

Invoke slot-clicked event and show action menu.

public virtual

SetItem(ItemStack itemStack)

bool

Assign new stack if allowed; invoke onItemUpdated and refresh.

public virtual

RemoveItem()

void

Clear the slot, invoke onItemUpdated, and refresh.

protected

DragStartedHandler()

void

Initialize drag proxy and add it to the global drag area.

protected

DragHandlerImmediate(GeometryChangedEvent e)

void

Immediately update drag proxy position after it’s added.

protected virtual

DragHandler()

void

Move drag proxy to follow pointer movements.

protected virtual

DropHandler()

void

Remove drag proxy and close hover details if this slot was target.

protected virtual

OpenActionMenu()

void

Display context menu if an item is present and options exist.

public virtual

Refresh()

void

Update icon, background, and amount; re-open hover if still target.


Last updated