Skip to content

Commit

Permalink
triggerWhenMouseDownOnObjects, down action for point
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp authored and jaltekruse committed Feb 24, 2023
1 parent 34e5d68 commit fa02d92
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 4 deletions.
13 changes: 13 additions & 0 deletions src/Core/components/CallAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ export default class CallAction extends InlineComponent {
createTargetComponentNames: true,
}

attributes.triggerWhenMouseDownOnObjects = {
createTargetComponentNames: "string"
}

attributes.numbers = {
createComponentOfType: "numberList",
};
Expand Down Expand Up @@ -169,6 +173,10 @@ export default class CallAction extends InlineComponent {
dependencyType: "attributeTargetComponentNames",
attributeName: "triggerWhenObjectsClicked"
},
triggerWhenMouseDownOnObjects: {
dependencyType: "attributeTargetComponentNames",
attributeName: "triggerWhenMouseDownOnObjects"
},
triggerWhen: {
dependencyType: "attributeComponent",
attributeName: "triggerWhen"
Expand All @@ -194,6 +202,11 @@ export default class CallAction extends InlineComponent {
triggerWith.push({ target: nameObj.absoluteName, triggeringAction: "click" })
}
}
if (dependencyValues.triggerWhenMouseDownOnObjects !== null) {
for (let nameObj of dependencyValues.triggerWhenMouseDownOnObjects) {
triggerWith.push({ target: nameObj.absoluteName, triggeringAction: "down" })
}
}

if (triggerWith.length === 0) {
triggerWith = null;
Expand Down
13 changes: 13 additions & 0 deletions src/Core/components/Point.js
Original file line number Diff line number Diff line change
Expand Up @@ -1235,10 +1235,23 @@ export default class Point extends GraphicalComponent {
}


async mouseDownOnPoint({ actionId }) {

await this.coreFunctions.triggerChainedActions({
triggeringAction: "down",
componentName: this.componentName,
})

this.coreFunctions.resolveAction({ actionId });

}


actions = {
movePoint: this.movePoint.bind(this),
switchPoint: this.switchPoint.bind(this),
pointClicked: this.pointClicked.bind(this),
mouseDownOnPoint: this.mouseDownOnPoint.bind(this),
};

}
13 changes: 13 additions & 0 deletions src/Core/components/TriggerSet.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export default class triggerSet extends InlineComponent {
createTargetComponentNames: true,
}

attributes.triggerWhenMouseDownOnObjects = {
createTargetComponentNames: "string"
}

return attributes;
}

Expand Down Expand Up @@ -82,6 +86,10 @@ export default class triggerSet extends InlineComponent {
dependencyType: "attributeTargetComponentNames",
attributeName: "triggerWhenObjectsClicked"
},
triggerWhenMouseDownOnObjects: {
dependencyType: "attributeTargetComponentNames",
attributeName: "triggerWhenMouseDownOnObjects"
},
triggerWhen: {
dependencyType: "attributeComponent",
attributeName: "triggerWhen"
Expand All @@ -102,6 +110,11 @@ export default class triggerSet extends InlineComponent {
triggerWith.push({ target: nameObj.absoluteName, triggeringAction: "click" })
}
}
if (dependencyValues.triggerWhenMouseDownOnObjects !== null) {
for (let nameObj of dependencyValues.triggerWhenMouseDownOnObjects) {
triggerWith.push({ target: nameObj.absoluteName, triggeringAction: "down" })
}
}

if (triggerWith.length === 0) {
triggerWith = null;
Expand Down
13 changes: 13 additions & 0 deletions src/Core/components/UpdateValue.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export default class UpdateValue extends InlineComponent {
createTargetComponentNames: "string"
}

attributes.triggerWhenMouseDownOnObjects = {
createTargetComponentNames: "string"
}

// for newValue with type==="math"
// let simplify="" or simplify="true" be full simplify
attributes.simplify = {
Expand Down Expand Up @@ -325,6 +329,10 @@ export default class UpdateValue extends InlineComponent {
dependencyType: "attributeTargetComponentNames",
attributeName: "triggerWhenObjectsClicked"
},
triggerWhenMouseDownOnObjects: {
dependencyType: "attributeTargetComponentNames",
attributeName: "triggerWhenMouseDownOnObjects"
},
triggerWhen: {
dependencyType: "attributeComponent",
attributeName: "triggerWhen"
Expand All @@ -350,6 +358,11 @@ export default class UpdateValue extends InlineComponent {
triggerWith.push({ target: nameObj.absoluteName, triggeringAction: "click" })
}
}
if (dependencyValues.triggerWhenMouseDownOnObjects !== null) {
for (let nameObj of dependencyValues.triggerWhenMouseDownOnObjects) {
triggerWith.push({ target: nameObj.absoluteName, triggeringAction: "down" })
}
}

if (triggerWith.length === 0) {
triggerWith = null;
Expand Down
10 changes: 6 additions & 4 deletions src/Viewer/renderers/point.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ export default React.memo(function Point(props) {
dragged.current = false;
shadowPointJXG.current.visProp.fillopacity = pointJXG.current.visProp.fillopacity;
shadowPointJXG.current.visProp.strokeopacity = pointJXG.current.visProp.strokeopacity;

callAction({
action: actions.mouseDownOnPoint
});
});

newShadowPointJXG.on('up', function (e) {
Expand Down Expand Up @@ -262,7 +264,7 @@ export default React.memo(function Point(props) {
//if values update
let fillColor = useOpenSymbol ? "var(--canvas)" : SVs.selectedStyle.markerColor;
let strokeColor = useOpenSymbol ? SVs.selectedStyle.markerColor : "none";

if (pointJXG.current.visProp.fillcolor !== fillColor) {
pointJXG.current.visProp.fillcolor = fillColor;
}
Expand Down Expand Up @@ -447,8 +449,8 @@ function normalizeSize(size, style) {
} else if (style === "plus") {
return size * 1.2;
} else if (style === "square") {
return size * 1.1;
} else if (style.substring(0,8) === "triangle") {
return size * 1.1;
} else if (style.substring(0, 8) === "triangle") {
return size * 1.5;
} else return size;
}
Expand Down

0 comments on commit fa02d92

Please sign in to comment.