Is it possible to tell the what context a view is in when an action is performed? For example, if a button as an actionPerformed script, could I examine some property of the object or the event which would tell me if the view was the primary view of a page, or if it was embedded inside another view?
Not unless you’ve manually specified a hard-coded value for the View’s path. bindings against
page.props.primaryView will return the path of the View from the
So, in theory, if you supply a custom property key of “path” for your view node and you supply the known path to that View, then you could perform the following check:
if self.view.custom.path == self.page.primaryView: # do something
This will only tell you if the Primary View for the page is the View in question, and there is every possibility that your primary View has an instance of your View embedded within it somehow, such that
ViewA has some components, and at least one of them is an embedding component, and that embedding component is rendering another instance of ViewA.
In this event, your check will pass as the instanced View has the same path as the primary View for the page.
TLDR; There is no way to know with 100% certainty whether your “current” View is the primary View of a page.
That all makes sense. Thank you for the explanation.