How to change perspective component value from tag event

How is it possible to change perspective component value from tag event
For example: I want to change ‘text’ of ‘Label_0’ when the value of tag ‘TAG1’ changes.

I tried this, but I guess the calling syntax


is incorrect.

Tag Event Script / Value Events / Value Changed:

def valueChanged(tag, tagPath, previousValue, currentValue, initialChange, missedEvents):
    self.getSibling("Label_0").props.text = currentValue.value

EDIT: yes I know it’s possible to do binding from component to tag… but need specifically from tag => comoponent… and this example was simplified

Think about it in the reverse way. Don’t have your tag write to the text component, have your text component read your tag value.

In your components text field, bind to the tag value to display the tag data.

1 Like

thanks for the suggestion, I am aware about binding… but I need to have it exactly as I described… from tag to label…because of the nature of the task. And this is a simplified example.

If you use the property selector tool to choose your label, does it give you the same self.getSibling("Label_0") path, or something different?

PGriffith, if I would try to browse to the needed component value from another component => yes, I get same syntax. See screenshot

But I am looking for a way to access component value from withing Tag Event Script.

There is no correct syntax. Tags are global. By themselves, they have no knowledge of what clients/pages/views are open, and no access to the components within them. So, within the tag, your only option is to send a broadcast message to all Perspective sessions, expecting a session message handler to re-broadcast it where you need.

Conversely, your session/page/view can bind the tag to a property (not necessarily directly to the label text), and a propertyChange action can then dispatch it within the context/scope where it is bound.

You need to flip the paradigm in your head.


Thanks! Can you please share an example of code on how to send a broadcast message to all Perspective sessions?

I don’t have an example because I would never do this. It is the wrong approach.