How-To: Bind a Slot Widget
Goal: a complete slot widget - icon, keybind, cooldown sweep, count badge, gray-out, click, drag-out, drop-in - that reads only the snapshot and never touches the ability system or the inventory.
GetSlotCount(BarTag).1. Subscribe and seed
Event Construct -> Find (Crimson Action Bar Component) -> store it. Bind Event to On Slot Changed, On Slot Live State Changed, On Slot Highlight Changed, On Slot Input Pressed. Then Get Slot State for your address and call your handlers once so the widget is right on the first frame.
2. Identity: On Slot Changed
Fires when the static half changes: bound / cleared / stale / locked / keybind text / display. Rebuild the icon, name, keybind label and lock glyph here. Compare Address to your own (the delegate is per component, not per slot).
Handler: Branch (Address == MyAddress) -> Set Brush from Soft Texture (State.Display.Icon), Set Text (State.KeybindText), gray if State.Stale, padlock if State.Locked.
3. Live: On Slot Live State Changed
Fires on edges only: enabled, cost, cooldown started / ended / restarted, charges, count, active. Never per frame. Drive the gray-out, the resource tint, the count badge and the start of a sweep here.
Handler: gray if not State.Live.Enabled; blue tint if not State.Live.CostMet; count text from State.Live.Count (hide when -1); charges from State.Live.Charges / MaxCharges; a current frame when State.Live.Active.
4. The sweep
Interpolate from the snapshot's end times on your own tick; do not poll the component per frame. A regular cooldown wins over the global one when it is longer.
Event Tick -> Get Slot State -> if State.CooldownEndWorldTime > 0: Remaining = EndTime - Get Game Time in Seconds, Percent = Remaining / State.Live.CooldownDuration -> Set Percent on the sweep material / progress bar. Same with GlobalCooldownEndWorldTime / Live.GlobalCooldownDuration when it is the longer of the two.
Enabled = true.5. Click, drag out, drop in
On Clicked -> Press Slot then Release Slot (address). On Drag Detected: if not Are Bars Locked, create your drag operation carrying State.Binding and the address. On Drop: if the payload has an address -> Move Binding (from, to); if it carries a binding from a picker -> Can Assign Binding (show Reason on false) then Assign Binding.
FCrimsonSlotBinding (plus a display preview if you want one) - and the same slot widget takes drops from every view over the store: a picker, a spellbook, a radial wheel. Accept the operation, read its Binding, pre-flight with Can Assign Binding, assign.6. Or start from CrimsonCore's slot widget
Everything above is the raw plugin surface. CrimsonCore's UCrimsonCoreActionBarSlotWidget (W_ActionBar_Slot) already does all of it in C++ - subscribes, seeds, sweeps, drags, drops - and owns its whole look as class defaults (SlotMaterial, MaterialBinding, Visuals; the layout asset holds no look). Subclass it when you want a different look without redoing the plumbing: override Apply Appearance or leave the material pass in place and react to the events below, which fire only when the state actually flips, so an animation started on true can be stopped on false.
| Event | Fires when |
|---|---|
| On Slot Changed / On Live State Changed / On Highlight Changed | Identity, live state or proc glow changed (the plugin's own signals, forwarded). |
| On Key Pressed / On Key Released / On Activation Refused | The slot's key edge, or a press the plugin refused (empty, stale, disabled). |
| On Hover Changed | The pointer entered / left the slot. |
| On Press Changed | Pressed / released, by mouse or by the slot's key. |
| On Drag State Changed | This slot's binding is being dragged out / the drag ended anywhere. |
| On Drop Feedback Changed | A drag moved over the slot: Accept, Refuse, or None when it left. |
| On Cooldown Changed | A cooldown (own or global) started sweeping (with remaining / total seconds) or every sweep finished. |
| On Active Changed | The bound thing became active (channel / toggle on) or stopped. |
| On Stale Changed | The binding stopped resolving (unlearned, sold) or resolves again. |
| On Edit Lock Changed | The player may / may not change the slot: slot lock, server-only, or the bars locked in combat (not CommonUI's button lock). |
| On Availability Changed | Enabled (usable right now) and / or cost payable flipped. |
See also
- Concept: Providers and Identity
- API Reference -> Snapshots