From 7b2b3de788eb037721e7ba357ebacc7286c3d83d Mon Sep 17 00:00:00 2001 From: thepaperpilot Date: Wed, 2 Mar 2022 21:34:32 -0600 Subject: [PATCH] Fixed lifting up on certain elements not stopping the auto-clicker --- src/features/clickables/Clickable.vue | 1 - src/features/clickables/clickable.ts | 18 ++++++++++++++++++ src/features/grids/GridCell.vue | 1 - src/features/grids/grid.ts | 17 +++++++++++++++++ src/features/trees/TreeNode.vue | 1 - src/features/trees/tree.ts | 17 +++++++++++++++++ 6 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/features/clickables/Clickable.vue b/src/features/clickables/Clickable.vue index d8b5b4a..e5e3297 100644 --- a/src/features/clickables/Clickable.vue +++ b/src/features/clickables/Clickable.vue @@ -12,7 +12,6 @@ @touchstart="start" @touchend="stop" @touchcancel="stop" - :disabled="!unref(canClick)" :class="{ feature: true, clickable: true, diff --git a/src/features/clickables/clickable.ts b/src/features/clickables/clickable.ts index df991ca..40ddbf2 100644 --- a/src/features/clickables/clickable.ts +++ b/src/features/clickables/clickable.ts @@ -17,6 +17,7 @@ import { ProcessedComputable } from "@/util/computed"; import { createLazyProxy } from "@/util/proxies"; +import { unref } from "vue"; export const ClickableType = Symbol("Clickable"); @@ -83,6 +84,23 @@ export function createClickable( processComputable(clickable as T, "mark"); processComputable(clickable as T, "display"); + if (clickable.onClick) { + const onClick = clickable.onClick; + clickable.onClick = function () { + if (unref(clickable.canClick)) { + onClick(); + } + }; + } + if (clickable.onHold) { + const onHold = clickable.onHold; + clickable.onHold = function () { + if (unref(clickable.canClick)) { + onHold(); + } + }; + } + clickable[GatherProps] = function (this: GenericClickable) { const { display, diff --git a/src/features/grids/GridCell.vue b/src/features/grids/GridCell.vue index fb88b67..b2903de 100644 --- a/src/features/grids/GridCell.vue +++ b/src/features/grids/GridCell.vue @@ -15,7 +15,6 @@ @touchstart="start" @touchend="stop" @touchcancel="stop" - :disabled="!unref(canClick)" >
diff --git a/src/features/grids/grid.ts b/src/features/grids/grid.ts index 3c6ab97..7d4fc71 100644 --- a/src/features/grids/grid.ts +++ b/src/features/grids/grid.ts @@ -278,6 +278,23 @@ export function createGrid( processComputable(grid as T, "getTitle"); processComputable(grid as T, "getDisplay"); + if (grid.onClick) { + const onClick = grid.onClick; + grid.onClick = function (id, state) { + if (unref((grid as GenericGrid).cells[id].canClick)) { + onClick(id, state); + } + }; + } + if (grid.onHold) { + const onHold = grid.onHold; + grid.onHold = function (id, state) { + if (unref((grid as GenericGrid).cells[id].canClick)) { + onHold(id, state); + } + }; + } + grid[GatherProps] = function (this: GenericGrid) { const { visibility, rows, cols, cells, id } = this; return { visibility, rows, cols, cells, id }; diff --git a/src/features/trees/TreeNode.vue b/src/features/trees/TreeNode.vue index 97f639e..103ffba 100644 --- a/src/features/trees/TreeNode.vue +++ b/src/features/trees/TreeNode.vue @@ -29,7 +29,6 @@ }, unref(style) ?? [] ]" - :disabled="!unref(canClick)" > diff --git a/src/features/trees/tree.ts b/src/features/trees/tree.ts index e9be03b..540c9b3 100644 --- a/src/features/trees/tree.ts +++ b/src/features/trees/tree.ts @@ -101,6 +101,23 @@ export function createTreeNode( processComputable(treeNode as T, "style"); processComputable(treeNode as T, "mark"); + if (treeNode.onClick) { + const onClick = treeNode.onClick; + treeNode.onClick = function () { + if (unref(treeNode.canClick)) { + onClick(); + } + }; + } + if (treeNode.onHold) { + const onHold = treeNode.onHold; + treeNode.onHold = function () { + if (unref(treeNode.canClick)) { + onHold(); + } + }; + } + return treeNode as unknown as TreeNode; }); }