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
I did that and it opens my popup every time I click on the menu tree, I just need it to open my popup when I click certain buttons on the menu tree. I attached a screenshot of the menu tree, when I click on Condenser Setpoints I want it to open the popup for that which is item 4.
Check out this link, you can get things like target, path, or label.
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
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..
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.
That works, thank you. Do you know how to get the menu to auto hide after clicking on the popup button? I have the menu set to auto hide so after i press a button it closes but with these popups it stays open.
What is actually happening when it "auto hides," are you toggling the visible prop, or something else?
Im not doing anything to make the menu bar hide, it does it automatically after a selection is made. Screenshot of how i have my menu bar setup.
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.