diff --git a/src/data/common.tsx b/src/data/common.tsx index 3f68007..638bc7d 100644 --- a/src/data/common.tsx +++ b/src/data/common.tsx @@ -73,7 +73,7 @@ export type ResetButton = Replace< display: GetComputableTypeWithDefault>; canClick: GetComputableTypeWithDefault>; minimumGain: GetComputableTypeWithDefault; - onClick: VoidFunction; + onClick: (event?: MouseEvent | TouchEvent) => void; } >; @@ -153,7 +153,7 @@ export function createResetButton( if (grid.onClick) { const onClick = grid.onClick.bind(grid); - grid.onClick = function (id, state) { + grid.onClick = function (id, state, e) { if (unref((grid as GenericGrid).cells[id].canClick)) { - onClick(id, state); + onClick(id, state, e); } }; } diff --git a/src/features/repeatable.tsx b/src/features/repeatable.tsx index f40f61c..8bceaf6 100644 --- a/src/features/repeatable.tsx +++ b/src/features/repeatable.tsx @@ -79,7 +79,7 @@ export interface BaseRepeatable { /** Whether or not this repeatable can be clicked. */ canClick: ProcessedComputable; /** A function that gets called when this repeatable is clicked. */ - onClick: VoidFunction; + onClick: (event?: MouseEvent | TouchEvent) => void; /** A symbol that helps identify features of the same type. */ type: typeof RepeatableType; /** The Vue component used to render this feature. */ @@ -172,7 +172,7 @@ export function createRepeatable( }); repeatable.canClick = computed(() => requirementsMet(repeatable.requirements)); const onClick = repeatable.onClick; - repeatable.onClick = function (this: GenericRepeatable) { + repeatable.onClick = function (this: GenericRepeatable, event?: MouseEvent | TouchEvent) { const genericRepeatable = repeatable as GenericRepeatable; if (!unref(genericRepeatable.canClick)) { return; @@ -184,7 +184,7 @@ export function createRepeatable( : 1 ); genericRepeatable.amount.value = Decimal.add(genericRepeatable.amount.value, 1); - onClick?.(); + onClick?.(event); }; processComputable(repeatable as T, "display"); const display = repeatable.display; diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index 0b36f74..99c759a 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -87,9 +87,9 @@ export function createTreeNode( if (treeNode.onClick) { const onClick = treeNode.onClick.bind(treeNode); - treeNode.onClick = function () { + treeNode.onClick = function (e) { if (unref(treeNode.canClick) !== false) { - onClick(); + onClick(e); } }; }