I have some popups that I want to open from my menu tree and I can't figure out how to do it. I saw a couple places in the forum where people were talking about using the onItemClicked event but I'm not sure where to put that event?
You don't put the event anywhere, you just configure it to do something on that event. Right click the component and select Configure Events. Select onItemClicked, add a Script function, then write your logic. It should start like this:
if event.enabled:
if event.label == 'Some Item':
# do something
elif event.label == 'Another Item':
# do something else
Check out this link, you can get things like target, path, or label.
https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Menu+Tree#PerspectiveMenuTree-ComponentEvents
I looked through there and I can't figure out how to make it work. I can make it open full screen size from the menu tree but not as a popup.
Post your script and format it with the </> button
I think this is because you want to use a component that really isn't it's intended purpose.
I would try to put the path into the target property and then disable that item. You will need to call the popup in the event.
Ok i added the target and disabled the item. How do i get a button press on the Condenser Setpoints button to run the script below. The script works on a button on the screen but i don't know where to put the script to make the menu tree button run it to open it as a popup.
def runAction(self, event):
system.perspective.openPopup("myPopupId", 'Page/CondenserSP')
The view path is event.target, you will need to enter the appropriate popup path into the target..
https://docs.inductiveautomation.com/display/DOC81/system.perspective.openPopup
I'm assuming a bit on this as I haven't tested.
Edit, just to clarify, the event is onItemClicked as @dkhayes117 mentioned above.
Of course your popup will open with every single click, you aren't filtering the event. The event is fired everytime you click an item in the component with properties about what you clicked on; therefore, openPopup is called every single time since you aren't filtering out which label you want to act on.
- re-enable the item
- remove the target path
- use this script
- I do this same thing too, I know it works
def runAction(self, event):
if event.enabled:
if event.label == 'Condenser Setpoints':
system.perspective.openPopup("myPopupId", 'Page/CondenserSP')
elif event.label == 'WATER CHILLER':
# do something else
To see those properties I mentioned on each click, you can do this to see them in the output console (Ctrl+Shift+c)
def runAction(self, event):
system.perspective.print(event)
Thank you, I wasn't sure how to filter it but that makes sense now.
What is actually happening when it "auto hides," are you toggling the visible prop, or something else?
I haven't run into this, because I always keep the nav bar visible and don't hide it. It's not an elegant solution, but it does work. Bind any of your popup option's target property to page.props.path. This will navigate back to the same page which will trigger the menu tree to hide without actually navigating anywhere.
Thanks ill try that.





