Open popup at bottom right corner of the window

Hi,

I like to open the popup at bottom right corner of the window

how to do that

i have tired like this

window = system.nav.openWindow('Common/Feedback')
system.nav.bottomRightWindow(window)

but its throwing error

The user manual system.nav page doesn't list a function bottomRightWindow. Did you just make it up in hope or am I missing something?

https://docs.inductiveautomation.com/display/DOC80/system.nav

Yes its not mentioned

I just tired

Is there any way to do that?

window = system.nav.openWindow('Common/Feedback')
window.setLocation(200, 50)

Set Location depends upon the screen resolution right?

I tired it showing in Left top corner

1 Like

From your script got the resolution

resolution: 1920 x 1080
dpi: 96
scaleX: 1.0
scaleY: 1.0

how to identify the left bottom corner position?

This assumes that your window is full screen, which I do not feel is correct. You need to get your parent window size. To position a popup on the left side of the parent window, your x coordinate is going to be 0. To position a popup at the bottom of the parent window, your y coordinate will be the height of the parent window minus the height of the popup window.

The code will need to look something like this:

parentWindow = system.gui.getParentWindow(event)
popup = system.nav.openWindow('Popup')
x = 0
y = parentWindow.height - popup.height
popup.setLocation(x, y)

Edit: I should note that height is an absolute property that is measured in pixels. Therefore, there shouldn't be any need to consider screen resolution; it will already be accounted for.

2 Likes

@justinedwards.jle
Is there any way to run this script in vision client timer?

when used in vision client timer - throwing error parentWindow = system.gui.getParentWindow(event)

It should work just fine from a timer. What event handler was used? How was the script qualified? What was the error?

Probably no event. This would work best in the internalFrameActivated event of the popup, IMO.

1 Like

Yes jordan is correct... there is no event error

i found a alternative

system.gui.getOpenedWindows()

using this i can get the open window

but one issue is it's fetching all the windows(popup too) - i need to filter that's the trick

1 Like

You could do something like:

for window in system.gui.getOpenedWindows():
     if window.name == 'yourWindowName':
          parentWindow = window
          break

...but if you are doing it from the internalFrameOpened event handler of the popup, it doesn't seem appropriate to assume that the popup was launched from is nested in a specific window. If I remember correctly, you can use swing utilities to get the window the popup was launched from is nested in. The script would look like this:

from javax.swing import JFrame, SwingUtilities
popup = event.source
parentWindow = SwingUtilities.getAncestorOfClass(JFrame, popup)
x = 0
y = parentWindow.height - popup.height
popup.setLocation(x, y)
1 Like

no i am writing the script in vision client timer

No, SwingUtilities has no insight into the call chain. It follows the component hierarchy. Windows belong to a desktop.

I could have swore I had used this approach in other scenarios with success. To confirm, I set up a test, and the script worked as expected with the popup appearing in the lower left of the parent window:

...so I assume the issue with my statement is semantical. I should have said the window the popup is nested in instead of launched from? ...or is there some other concept I need to learn to frame this correctly?

Yes, a popup can be launched into a different desktop by a script. You won't have any information about the caller, just where the desktop opened.

1 Like