Fix issue #84: Double click token
All checks were successful
Test / test (push) Successful in 2s

This commit is contained in:
Gitea OpenCode Agent
2026-10-15 20:44:53 +00:00
parent 2c1cc970e6
commit 5ee7353123
3 changed files with 25 additions and 3 deletions

View File

@@ -436,6 +436,14 @@ async function onTokenPointerUp(event) {
await placeToken(token.actor, { x, y });
}
// Double clicking a token (or Enter on a focused one) opens the sheet of the actor it stands for.
// A single click cannot be the trigger: the click that ends a drag lands on the token too, so
// dragging a token over the map would open its sheet every time.
function openTokenSheet(token) {
const actor = tokenActor(token);
if (actor) openActorSheet(actor);
}
const CELL_STEPS = {
ArrowLeft: [-1, 0],
ArrowRight: [1, 0],
@@ -443,7 +451,8 @@ const CELL_STEPS = {
ArrowDown: [0, 1]
};
// A focused token answers to the keyboard too: arrows walk it over the grid, Delete takes it off.
// A focused token answers to the keyboard too: arrows walk it over the grid, Delete takes it off
// and Enter opens its sheet, the way a double click does.
async function onTokenKeydown(event, token) {
const step = CELL_STEPS[event.key];
if (step) {
@@ -456,6 +465,7 @@ async function onTokenKeydown(event, token) {
event.preventDefault();
await removeToken(token);
}
if (event.key === 'Enter') openTokenSheet(token);
}
function onTokenContextMenu(token) {
@@ -609,6 +619,7 @@ onBeforeUnmount(() => {
@pointermove="onTokenPointerMove"
@pointerup="onTokenPointerUp"
@pointercancel="onTokenPointerUp"
@dblclick="openTokenSheet(token)"
@contextmenu.stop.prevent="onTokenContextMenu(token)"
@keydown="onTokenKeydown($event, token)"
>