Vertically center popup but fixed X position

Using Windows and Ignition 8.1

I have a navigation popup that due to animation can’t be a docked window, and I need to set the popup location to a fixed X position (0), but vertically centered in the screen.

I’m opening the popup using the system.nav.swapTo() function and then using .setLocation on the returned window object.

Right now we are using the system.gui.getScreens() to get the screen height, but that doesn’t take into consideration the scale factor that might be present on that screen.

Is there anyway to use the .setLocation to set the window vertically centered? Or is there a way to grab the scaling factor used on the screen? Or even better get the actual usable resolution of the screen with the scaling factor applied?

You can see what information Java has via the singleton Toolkit and GraphicsEnvironment classes.
It seems that toolkit.getScreenResolution() is your best bet.

1 Like

I ended up using this (basically) to get similar information but with accurate dimensions for the screens:

	ge = GraphicsEnvironment.getLocalGraphicsEnvironment()
	screens = []
	i = 0
	for gd in ge.getScreenDevices():
		gb = gd.getDefaultConfiguration().getBounds()
		screens.append([i,gb.width,gb.height])
		i+=1

When I take a look at the screens array, now I get a tuple with the correct height and width of the screen based on the scale factor set on the screen… and it works like a charm!

Thanks for the help @PGriffith

1 Like