Bind onClick and onHold functions before wrapping them
This commit is contained in:
parent
8170f240c8
commit
de4bb44e02
3 changed files with 6 additions and 6 deletions
|
@ -87,7 +87,7 @@ export function createClickable<T extends ClickableOptions>(
|
||||||
processComputable(clickable as T, "display");
|
processComputable(clickable as T, "display");
|
||||||
|
|
||||||
if (clickable.onClick) {
|
if (clickable.onClick) {
|
||||||
const onClick = clickable.onClick;
|
const onClick = clickable.onClick.bind(clickable);
|
||||||
clickable.onClick = function () {
|
clickable.onClick = function () {
|
||||||
if (unref(clickable.canClick)) {
|
if (unref(clickable.canClick)) {
|
||||||
onClick();
|
onClick();
|
||||||
|
@ -95,7 +95,7 @@ export function createClickable<T extends ClickableOptions>(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (clickable.onHold) {
|
if (clickable.onHold) {
|
||||||
const onHold = clickable.onHold;
|
const onHold = clickable.onHold.bind(clickable);
|
||||||
clickable.onHold = function () {
|
clickable.onHold = function () {
|
||||||
if (unref(clickable.canClick)) {
|
if (unref(clickable.canClick)) {
|
||||||
onHold();
|
onHold();
|
||||||
|
|
|
@ -279,7 +279,7 @@ export function createGrid<T extends GridOptions>(
|
||||||
processComputable(grid as T, "getDisplay");
|
processComputable(grid as T, "getDisplay");
|
||||||
|
|
||||||
if (grid.onClick) {
|
if (grid.onClick) {
|
||||||
const onClick = grid.onClick;
|
const onClick = grid.onClick.bind(grid);
|
||||||
grid.onClick = function (id, state) {
|
grid.onClick = function (id, state) {
|
||||||
if (unref((grid as GenericGrid).cells[id].canClick)) {
|
if (unref((grid as GenericGrid).cells[id].canClick)) {
|
||||||
onClick(id, state);
|
onClick(id, state);
|
||||||
|
@ -287,7 +287,7 @@ export function createGrid<T extends GridOptions>(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (grid.onHold) {
|
if (grid.onHold) {
|
||||||
const onHold = grid.onHold;
|
const onHold = grid.onHold.bind(grid);
|
||||||
grid.onHold = function (id, state) {
|
grid.onHold = function (id, state) {
|
||||||
if (unref((grid as GenericGrid).cells[id].canClick)) {
|
if (unref((grid as GenericGrid).cells[id].canClick)) {
|
||||||
onHold(id, state);
|
onHold(id, state);
|
||||||
|
|
|
@ -101,7 +101,7 @@ export function createTreeNode<T extends TreeNodeOptions>(
|
||||||
processComputable(treeNode as T, "mark");
|
processComputable(treeNode as T, "mark");
|
||||||
|
|
||||||
if (treeNode.onClick) {
|
if (treeNode.onClick) {
|
||||||
const onClick = treeNode.onClick;
|
const onClick = treeNode.onClick.bind(treeNode);
|
||||||
treeNode.onClick = function () {
|
treeNode.onClick = function () {
|
||||||
if (unref(treeNode.canClick)) {
|
if (unref(treeNode.canClick)) {
|
||||||
onClick();
|
onClick();
|
||||||
|
@ -109,7 +109,7 @@ export function createTreeNode<T extends TreeNodeOptions>(
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (treeNode.onHold) {
|
if (treeNode.onHold) {
|
||||||
const onHold = treeNode.onHold;
|
const onHold = treeNode.onHold.bind(treeNode);
|
||||||
treeNode.onHold = function () {
|
treeNode.onHold = function () {
|
||||||
if (unref(treeNode.canClick)) {
|
if (unref(treeNode.canClick)) {
|
||||||
onHold();
|
onHold();
|
||||||
|
|
Loading…
Reference in a new issue