Getting object of parent view from embedded view via scripting

Hello.

So, I have a template view (let’s say view X) in parent project. I am placing this template view in child project’s view (view Y) as an Embedded View Component.

My question is, am I able to get the child’s view object (Y) from template view (X) scripting? So in more general words, am I able to get any component object which is outside Embedded View via scripting?

Best regards,
Maciek

Suppose you have ViewX and ViewY. ViewX contains an Embedded View, and that Embedded View supplies the path to ViewY, such that you can see ViewY rendered within ViewX.

The only properties you have access to are those which you see in the property editor, so no, you are not able to reference children of ViewY from any scripting in ViewX.

If you need to communicate with children of ViewY from within ViewX, there are three ways to do so. I’ll provide them in order of how much they make sense.

  1. params: if you need to tell ViewY about something - and potentially get information back - params are a fairly easy way to do so. I recommend using in/out params for most scenarios.
  2. Message Handling: While this requires setting up a whole message send/receive paradigm for the components in question, it is far more recyclable and prevents you the need to link bindings to the params.
  3. Bind values to custom session properties. This route works, but requires you to manage a growing list of properties at the session scale. Negligible performance degradation, but I have one project which has hundreds of properties, sometimes nested deep within objects. Whenever I need to reference such a property, I know it’ll be at least a few minutes before I can locate it.

The only properties you have access to are those which you see in the property editor, so no, you are not able to reference children of ViewY from any scripting in ViewX.

I think this explains everything what I wanted. My case is that I would like to set visible property of the Embeded View Component form the scripting in X. My goal was to just place X as an Embeded View and do nothing more (no additional bindings, no additional message handling), all inside X.

Thank you for help.

You’re welcome. you could use a component inside the view which is being embedded to broadcast a message, and then you could have the Embedded View listen for that broadcast and on hearing it set visible to false, or you could use a bidirectional param of the Embedded View to convey whether it should be hidden, and then bind visibility against that param.