# Open Popup Window on Cursor Position

**URL:** <https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574>\
**Category:** Ignition\
**Created:** [December 13, 2012, 2:02pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574 "2012-12-13T14:02:17Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pilotek](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@Pilotek](https://forum.inductiveautomation.com/u/Pilotek)\
**Post date:** [December 13, 2012, 2:02pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/1 "2012-12-13T14:02:17Z")

</div>

Please how to open popup window (e.g. “Mouse clicked” or “Mouse released” Event Handler on some button) at the cursor position?

What is the (dis)advantage of choosing “Mouse released” over “Mouse Clicked” as a “trigger” of some event?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 13, 2012, 6:40pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/2 "2012-12-13T18:40:17Z")

</div>

We always recommend using “Mouse Released” over “Mouse Clicked” because it will fire even if the component’s window is not in focus. If you want to open a window when a user clicks on a component you just need to call:`system.nav.openWindow("SomeWindow")`If you want to open a different window based on the cursor location over the component you can do the following:[code]x = event.x  
y = event.y

if x \> 100 and x \< 200 and y \> 100 and y \< 200:  
system.nav.openWindow(“Window1”)  
else:  
system.nav.openWindow(“Window2”)[/code]

---

<div class="post-metadata">

**Author:** ![Pilotek](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@Pilotek](https://forum.inductiveautomation.com/u/Pilotek)\
**Post date:** [December 13, 2012, 7:18pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/3 "2012-12-13T19:18:51Z")

</div>

Thank you Travis, I wondered why you used “Mouse released” in your Skeleton Projects and now it’s clear.

By the first question I meant other thing:  
How to position opening of popup window (it’s upper left corner) to the coordinates of mouse cursor when clicking the object (e.g. button, or pump, or motor-drive…)

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [December 13, 2012, 10:00pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/4 "2012-12-13T22:00:25Z")

</div>

Ah I see. You can do the following:`win = system.nav.openWindow("SomeWindow")
xOffset = 50
yOffset = 100
win.setLocation(event.x + xOffset, event.y + yOffset)`The offsets are for any docked windows that you may have.

---

<div class="post-metadata">

**Author:** ![Pilotek](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@Pilotek](https://forum.inductiveautomation.com/u/Pilotek)\
**Post date:** [December 14, 2012, 8:05am UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/5 "2012-12-14T08:05:06Z")

</div>

Works great, thank you.

Another question: How to ensure that some object (e.g. login popup windows’s “UserName” field) in opened popup window gets focus automatically (cursor in it prepared for editing) after opening the popup?

[I don’t know how I become familiar with all the “mysteries” (features) of scripting 🙂. Please advice some newbie source what to study first to get overview of possibilities (keywords, functions) of scripting.]

---

<div class="post-metadata">

**Author:** ![AlThePal](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/althepal/32/3603_2.png) [@AlThePal](https://forum.inductiveautomation.com/u/AlThePal)\
**Post date:** [December 14, 2012, 9:10am UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/6 "2012-12-14T09:10:21Z")

</div>

To set focus to a control on opening a window, look at the focus Events section in the user manual at Project Design / Windows, Components, and Templates / Event Handlers / Event Types. You’ll need to use the requestFocusInWindow() function in the visionWindowOpened event (or the internalFrameActivated event in a version of Ignition older than 7.3), making sure to wrap your code in a call to system.util.invokeLater.

Note that this only works for simple components like a Text Field. If you ever need to get it to work with more complicated components like a Text Area, see [this post](http://www.inductiveautomation.com/forum/viewtopic.php?f=81&t=8939&p=30056&hilit=set+focus#p30056).

To learn scripting, check out the user manual and search the forum. Asking questions is allowed too 🙂

---

<div class="post-metadata">

**Author:** ![Pilotek](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@Pilotek](https://forum.inductiveautomation.com/u/Pilotek)\
**Post date:** [December 14, 2012, 10:06am UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/7 "2012-12-14T10:06:48Z")

</div>

Thank you AlThePal, by the time I’ve found this in one of the Skeleton Projects:

`
system.gui.getParentWindow(event).getComponentForPath('Root Container.UsernameTextField').requestFocusInWindow()
`in the Popup windows’s Event Handlers internalFrame -\> internalFrameActivated  
and it works.

---

<div class="post-metadata">

**Author:** ![Pilotek](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@Pilotek](https://forum.inductiveautomation.com/u/Pilotek)\
**Post date:** [December 14, 2012, 12:32pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/8 "2012-12-14T12:32:40Z")

</div>

Another question concerned 😃

I have two docked windows: North - Header and West - Navigation Panel).  
On Navigation Panel I have the Label “Switch User” which (after mouse clicking) opens the popup window “Switch User” at the cursor position - the popup window is over all other windows and overlaps both docked windows. So far everything is OK.  
When I want to drag the popup window to a different position, it is possible only in the area of Main window (container).

Q: Is there a way to make a popup window which is on top of all other windows and can be moved even over docked windows?

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [December 14, 2012, 7:20pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/9 "2012-12-14T19:20:13Z")

</div>

There is no way to drag a window (with the mouse) over a docked window.

---

<div class="post-metadata">

**Author:** ![Pilotek](https://avatars.discourse-cdn.com/v4/letter/p/7ba0ec/32.png) [@Pilotek](https://forum.inductiveautomation.com/u/Pilotek)\
**Post date:** [December 16, 2012, 1:03pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/10 "2012-12-16T13:03:43Z")

</div>

OK, thank you Robert.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 14, 2022, 1:37pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/11 "2022-06-14T13:37:17Z")

</div>

Sorry to revive a very old thread but is this still the case? I recently refactored a tiny header to be a big header that contains filters for tables and so that a very hefty Tree component does not reload across screens. But now I find that I can’t seem to drag the popup up into the big header

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/3/232c55fadc5b86333aaf05009573fde6563c30b9.png)

is there still no way or work-around for this? It’s kind of a show stopper for me with this optimization refactor if I can’t bring the popup up - the header has a lot of real estate so the popups are far too low.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [June 14, 2022, 3:06pm UTC](https://forum.inductiveautomation.com/t/open-popup-window-on-cursor-position/5574/12 "2022-06-14T15:06:45Z")

</div>

Did not see this in my prior search but there is a solution already -

> [@Popup Window Dragging Over Docked Windows](https://forum.inductiveautomation.com/t/popup-window-dragging-over-docked-windows/57898/2):
>
> If you uncheck Prevent Popup/Docking Overlap, it will allow your popups to overlap the docked windows. I think the second question is due to having Infinite Desktop enabled.
