Repository navigation
For Module Authors
dxcufgb edited this page Nov 5, 2026
·
2 revisions
There is no API and no hooks to call: the menu is built from the Token HUD itself. A button you add to the Token HUD shows up in the menu by itself, and it still gets the clicks.
Hooks.on("renderTokenHUD", (hud, html) => {
const button = document.createElement("button");
button.type = "button";
button.className = "control-icon"; // must be a .control-icon in one of the HUD's .col columns
button.dataset.tooltip = "Light a torch"; // the menu entry's text
button.innerHTML = '<i class="fa-solid fa-fire"></i>';
button.addEventListener("click", () => { /* … */ });
button.addEventListener("contextmenu", () => { /* right-click on the menu entry */ });
html.querySelector(".col.right")?.append(button);
});-
Text: the button's
data-tooltip-text, elsedata-tooltip(localization keys work),aria-label,title,alt, its own text, or itsdata-action("toggleTorch" → "Toggle Torch"). -
Icon: a copy of the
img,svgoriinside the button (or its ownfa-classes). -
Clicks: the original button stays in the HUD, only hidden, and the menu dispatches
click(left-click) orcontextmenu(right-click) on it. Use those events (or the HUD'sdata-actionhandlers), not hover. -
State: the
activeclass on the button highlights the entry; toggle it and the menu follows. A button with thehiddenattribute orstyle.display = "none"gets no entry. -
Sub-menus: a button with
data-palette="key"opens the HUD element.palette[data-palette="key"]as a sub-menu. Its items are the[data-action],[data-status-id],.effect-controland.control-iconelements in it; items withdata-status-idare toggled withactor.toggleStatusEffect(id, { overlay })instead of clicked. More than 12 items get a filter box. - Timing: buttons added or removed after the HUD rendered are picked up too (the menu watches the columns).
- Entries come in the order of the HUD's buttons, followed by the entries for the optional modules. The players' menu on tokens they don't own shows no HUD buttons.
Changing these breaks the entries:
- Dxcufgb's lively tokens (
dxcufgbs-lively-tokens):api.open(), itsplayersCanUsesetting, and it hides its.dxlt-hudbutton. - Dxcufgb's damage dice trails (
dxcufgbs-dice-trails):api.open(). - Dxcufgb's token follower (
dxcufgbs-token-follower):api.follow(follower, leader),api.stop(follower)(token documents) and the token flagflags["dxcufgbs-token-follower"].leader({ tokenId, sceneId, name }). - Rideable (
Rideable):api.RideableFlags.isRiddenby(mount, rider)(andapi.RideableFlags.TokenisRideablemust exist),game.Rideable.ToggleMount(riders, mount), the token flagflags.Rideable.issetRideableFlag, in PF2e itsRideableTagsetting, and it hides Rideable's[data-action="mount"]button.
Dxcufgb's Workshop: every Foundry VTT project, video and changelog in one place · Support on Ko-fi · MIT License
Using it
For module authors
Help