Overlay in top right corner with diff screen resolutions

Hi,

I’m trying to create a button that will always be available in the top right corner. It should overlap the other screens so for this reason I think using the built in dock isn’t going to work.

To do this I have created a window that has a layer of 1000 and have placed a button in it.

My target resolution is 1280x1024 since this is what most of our HMIs run on. I set the x and y locations to 1180 and 0 (its 100 pixels wide) and this works well.

The problem is where the screen is running on a resolution that is different i.e. 1600x… On these wider screens the button appears closer towards the middle of the screen.

My question is how can I set it so that this window always appears in the top right corner. I imagine it would involve binding the position but am not sure exactly how to do this.

Can you set the screen position during load? I imagine I have to set the location parameter of the window but am not sure which event to use and how to set this property. Can you do it by passing parameters into the system.nav.openwindow() method?

I can get most of the way there using this code but am getting the error “property ‘Location’ does not exist in window ‘ML/NavigationBar’”

[code]import java.awt
toolkit = java.awt.Toolkit.getDefaultToolkit();
scrnsize = toolkit.getScreenSize();
mywidth = scrnsize.width
mypoint = java.awt.Point(mywidth-100,0)
print "Screen size : " + str(scrnsize.width)

system.nav.openWindow(“ML/NavigationBar”,{“Location”:mypoint})[/code]

Curious about this as there is a location property listed in the user manual under window properties?? :question:

I assume you are familiar with the basic layout options that allow you to float the button a fixed distance from the top right portion of the window. This would allow you to put a north docked window, which would force maximized “main” windows to be slightly shorter (not overlap).

Alternatively, you could place a copy of the same button on every window. This is a bit clunkly to manage, but saves you the vertical pixelspace if you really don’t want a header. If you go this route, I would have the button call a function (or use templated components), so if you need to change the action it occurs in one place as opposed to modifying each copy.

If neither of those meets your requirements, I’m sure it can be accomplished in script.

Ok got it to work with help from dave,

To make a window always open in a particular location relative to whatever resolution your clients screen is running in, do the following

Under window event handlers ->visionWindow->visionWindowOpened write the following code:

[code]import java.awt
toolkit = java.awt.Toolkit.getDefaultToolkit();
scrnsize = toolkit.getScreenSize();
mywidth = scrnsize.width

event.source.setLocation(mywidth-100,0)[/code]

Note that my application is for an always present floating button (100 pixels wide) that calls a drop down navigation menu. I’ve found this is an effective navigation strategy for clients running in full screen (without having screen realestate consumed by a docked navigation bar or menu bar at all times).

This code opens the navigation button in the top right of the screen which is most often in my experience a blank area of the screen.