I’m building a vertical navigation scheme in perspective using a menu component and a view canvas. The idea is when you click on an item in the menu, the canvas will scroll to the desired position (something like this: Sticky Sidebar Navigation on Scroll – CodeMyUI). The way I’m accomplishing this now is by adding the height of each instance in the view up to the one I want to navigate to, and then setting the “top” property of each instance to that value (each instance is set to “relative” position).
Script is similar to this:
# Menu onActionPerformed Event
self.view.custom.selection_pos = event.path[0]
# canvas_top custom prop with script binding to selection_pos
self.custom.canvas_top = -1 * sum(instance[“height”] for instance in self.props.instances[:self.view.custom.selection_pos])
Everything is working like I want, but right now I have to set the height of each instance so that I can add them. I would prefer to leave the height on “auto”. I noticed that the View Canvas component has an event action onInstanceClicked
, which you can use to get event.size.height
, which will return the actual height of the instance, not just the “auto” string.
The question is, how can I get the actual instance height when it’s set to “auto” without having to manually click on each instance. My first thought was that these heights must be exposed somewhere, but it doesn’t seem like there is a function to access them directly. My next thought was to somehow call the onInstanceClicked
event through scripting on each instance, but I can’t find a way to do this either. Any thoughts or ideas are greatly appreciated!