Creating a script for a circled shape based on a mouse click

Trying to create a script where if the circled shape is clicked its write a 1 to TAG1. If it is clicked again it writes a 0 to TAG1....... Trying to use the circled shape as a 2 state toggle, just turning something ON or OFF.

First thing, post code, not pictures of code. Please see Wiki - how to post code on this forum. It helps immensely by allowing others to copy & paste code to try it instead of trying to read & type from a picture. You can edit your post by clicking the pencil icon in the bottom right

Create a custom property on the component called selected or active or similar, and bidirectionaly bind it to the value of the tag. In your click script, put self.selected = not self.selected. The bidirectional binding will take care of the rest.

I would highly recommend making this item a template and passing the expected tag path in as a parameter. You can then indirectly bind to the passed tag path.

4 Likes