How to change shape properties by clicking #2638
-
IntroductionLet's say I have a button to change the color. How can I change the properties of a shape by clicking on it?I have to click on the shape, then change the color of the outline on the button and the shape should also change it. Even when you click on an element, the button should update and display the color of the currently selected element. I have the boundary tool and highlights installed on the figures. Steps to reproduceNo response Restrictions & ConstraintsNo response Does your question relate to JointJS or JointJS+. Select both if applicable.JointJS |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @makleo2002, Check out this tutorial on how to use click events in JointJS. When you click on a shape, it triggers a click event. This event gives you access to the shape’s details (model),which contains all the elements properties including its color. You can then use this color and assign it for a button. Similarly, when you change the button’s color, you can update the shape’s color with the new one. This way, the shape on your screen will reflect the new color. |
Beta Was this translation helpful? Give feedback.
I believe you’re setting a property using the syntax
model.attr("rect/fill","newColor")
. If that’s the case, you can retrieve that property usingmodel.attr("rect/fill")
. ORSince
model
is an object, you can access its properties in the same way you would with any other object. In other words, you can get their values directly from themodel
.