Open Popup Window on Cursor Position

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?

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:

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…)

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.

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 :slight_smile:. Please advice some newbie source what to study first to get overview of possibilities (keywords, functions) of scripting.]

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.

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

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.

Another question concerned :smiley:

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?

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

OK, thank you Robert.

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

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.

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