# Popup screen from a Menu tree Component?

**URL:** <https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 31, 2023, 4:02pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372 "2023-05-31T16:02:00Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [May 31, 2023, 4:02pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/1 "2023-05-31T16:02:00Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 31, 2023, 4:42pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/2 "2023-05-31T16:42:42Z")

</div>

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:

```python
if event.enabled:
	if event.label == 'Some Item':
		# do something
	elif event.label == 'Another Item':
		# do something else

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/0/f0cec8be419349d1e722b2f39fa57a5c521c0995.png)

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [May 31, 2023, 5:26pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/3 "2023-05-31T17:26:48Z")

</div>

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.

 ![MenuTree](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/1/e112e326dd5c9da9db35fcee447f483d3773b392.jpeg)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 31, 2023, 5:46pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/4 "2023-05-31T17:46:50Z")

</div>

Check out this link, you can get things like target, path, or label.  
[https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Menu+Tree#PerspectiveMenuTree-ComponentEvents](https://docs.inductiveautomation.com/display/DOC81/Perspective+-+Menu+Tree#PerspectiveMenuTree-ComponentEvents)

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [May 31, 2023, 7:23pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/5 "2023-05-31T19:23:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 31, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/6 "2023-05-31T19:31:38Z")

</div>

Post your script and format it with the `</>` button

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 31, 2023, 7:31pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/7 "2023-05-31T19:31:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [May 31, 2023, 7:46pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/8 "2023-05-31T19:46:23Z")

</div>

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.

 ![MenuTree](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/b/4b6d557b2de3f035f7e5d1c91a212a7f0049b06c.jpeg)

```auto
def runAction(self, event):
	system.perspective.openPopup("myPopupId", 'Page/CondenserSP')

```

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [May 31, 2023, 7:49pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/9 "2023-05-31T19:49:31Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 31, 2023, 7:57pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/10 "2023-05-31T19:57:20Z")

</div>

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.

1. re-enable the item
2. remove the target path
3. use this script
4. I do this same thing too, I know it works 🙂

```python
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)

```auto
def runAction(self, event):
	system.perspective.print(event)

```

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [June 1, 2023, 2:26pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/11 "2023-06-01T14:26:52Z")

</div>

Thank you, I wasn't sure how to filter it but that makes sense now.

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [June 1, 2023, 4:45pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/12 "2023-06-01T16:45:09Z")

</div>

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.

 ![condense](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/8/686e978b87a67fed9f1ed6c19f3d2eebc966123e.jpeg)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 1, 2023, 5:11pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/13 "2023-06-01T17:11:03Z")

</div>

What is actually happening when it "auto hides," are you toggling the visible prop, or something else?

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [June 1, 2023, 6:41pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/14 "2023-06-01T18:41:49Z")

</div>

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.

 ![00](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f1703ff50bbf3ca2629273eeabcbe15dc9a64204.jpeg)

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [June 1, 2023, 7:08pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/15 "2023-06-01T19:08:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Yash\_Patel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yash_patel/32/45025_2.png) [@Yash\_Patel](https://forum.inductiveautomation.com/u/Yash_Patel)\
**Post date:** [June 1, 2023, 7:15pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/16 "2023-06-01T19:15:01Z")

</div>

> [@John\_Williams](#):
>
> I have the menu set to auto hide so after i press a button it closes but with these

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/b/fbbbb1e7f9fac149b11224acab9ae3eb64dc55a6.png)  
This will resolve it!

---

<div class="post-metadata">

**Author:** ![John\_Williams](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@John\_Williams](https://forum.inductiveautomation.com/u/John_Williams)\
**Post date:** [June 1, 2023, 7:17pm UTC](https://forum.inductiveautomation.com/t/popup-screen-from-a-menu-tree-component/74372/17 "2023-06-01T19:17:04Z")

</div>

Thanks ill try that.
