Popup window and Window size and location problem

The button is in the main window where the popup should open.

the white area on the right side is space that is not being filled by the main window. I also wonder if there is a feature that sizes the window in exactly your screen size?

Ah, probably. We have it nicely aligned to the window though. :slight_smile:

So, we need to get the screen location of the root container, instead.

mainWindow = system.gui.getWindow('Window Name')
container = mainWindow.getRootContainer()

containerX = container.getLocationOnScreen().x

x = containerX + container.width - popup.width

This is the result I get now, still not the correct way.


this is the current button script:

mainWindow = system.gui.getWindow('L4/4_1_0_lijn4_Productielijn')

popup = system.nav.openWindow('CM/Popup')

container = mainWindow.getRootContainer()

containerX = container.getLocationOnScreen().x

x = containerX + container.width - popup.width
y = 103

popup.setLocation(x, y)

I find it weird that it makes the popup bigger than the main window itself when the size of the popup window is smaller.

It should get like this:

The first thing I want you to check in the designer is the popup's x and y parameters:
image

Make sure they are still 0. Then, your popup is really tall, so just temporarily, I want you to arbitrarily set the height to 500. My hypothesis is that in an actual session, the dimensions of the main window are smaller than they are in the designer, but the popup is so precisely sized to fit the main window that it ends up overflowing the bounds. This would cause the main window to scale in order to expand its bounds and accommodate the oversized or over positioned popup. That would explain the zooming behavior you have described.

Then, save this script on the button:

# Get the parent window
parentWindow = system.gui.getParentWindow(event)

# Get the parent width
parentWidth = parentWindow.width

# Get and open the popup
popup = system.nav.openWindow('CM/Popup')

# Calculate the desired coordinates for the popup's position
x = parentWidth - popup.width # Far right of Main Window
y = 0 # Top of Main Window

# Position the popup
popup.setLocation(x, y)

If this fixes the behavior in the session, put the height back to normal in the designer, and see if the popup positioning gets messed up again. If so, make the popup smaller, so it will open properly, and then, if it must be a precise height, dynamically resize it after it has opened.

The zoom thing has stopped and it is smaller but I just need to resize that by changing the height?

To resize it dynamically based on the parent window's session size, you will just have to get the parent window height, create a dimension, and adjust the popup's size. Integrating that into your existing code will look like this:

from java.awt import Dimension

# Get the parent window
parentWindow = system.gui.getParentWindow(event)

# Get the parent width and height
parentWidth = parentWindow.width
parentHeight = parentWindow.height

# Get and open the popup
popup = system.nav.openWindow('CM/Popup')

# Calculate the desired coordinates for the popup's position
x = parentWidth - popup.width # Far right of Main Window
y = 0 # Top of Main Window

# Position and resize the popup
popup.setLocation(x, y)
popup.setPreferredSize(Dimension(popup.width, parentHeight))
popup.setSize(Dimension(popup.width, parentHeight))

Thank you so much, this almost did the trick in the way I want it to be!! Thank you so much for your time. It saves me a lot of trouble.

1 Like