[bug-15735]system.gui.getScreenIndex() returns wrong Index

So this is a strange one.

We have a multi-monitor system that I’m using system.gui.getScreenIndex to get the screen index that the operator clicks on to properly show popups etc at the location of the mouse.

Old post

This all works fine, until I’m two functions deep.

Suppose I have two functions:

def functionA():
    Do stuff to figure out which popup to show etc...
    Call functionB
def functionB():
     Do stuff to position the popup

On the template I call functionA to determine the popup, which in turn calls functionB to position the popup.

If I have a button that calls functionA on a window that I know is screenIndex 1 and check system.gui.screenIndex it returns a 1. However if functionA then calls functionB and I check system.gui.screenIndex it returns a 0. Now… if I just straight up call functionB from the window it properly returns system.gui.screenIndex then 1 is returned not 0.

Any idea why? I can get around it in my code… I just wanted to bring this up and see if this is a known issue or not.

OK… so after more testing it isn’t the embedded function calling.

After I issue a system.nav.openWindowInstance the screen index is reset to 0. This occurs even when I specifically enumerate the desktop to open the window on with either the screen index or the desktop handle using system.nav.desktop(handle).openWindowInstance.

Any reason this is happening? I’ve got a work around… I just save the screen index before calling openWindowInstance but this seems to not be working as intended.

I ran a test on two monitors, with a window and a button with the following code:

def functionA():
    print system.gui.getCurrentDesktop()
    functionB()
    
def functionB():
    print system.gui.getCurrentDesktop()
    
functionA()

and received the correct results…

Monitor 1
Monitor 1
primary
primary

Running v7.9.12

Yeah… I did further testing and edited the original post.

It seems to be system.nav.openWindowInstance that is giving me fits.

And this is on 8.0.6 with a new function for screen handles.

For what it’s worth, I tested on 8.0.7 and received the same results as 7.9.12

This is the code I’m using to test.

window = 'Popups/Batch Plant/Edit/Ingredient'
print 'Index Position 1: %d' %(system.gui.getScreenIndex()) //Produces 1 as expected
system.nav.openWindowInstance(window)
print 'Index Position 2: %d' %(system.gui.getScreenIndex()) //Produces 0

@jlandwerlen can you test on yours? The window isn’t specific… can be any popup.

Thanks!

Confirmed. If I run the code you attached, only substituting the window path, it will behave just as you described.

OK that’s good I guess… :smiley: at least I know it isn’t me causing issues.

Hmm, I can see why you’d want getScreenIndex() to work this way, but I’m not sure if it’s possible with our current implementation…I’ll file a bug ticket.

Thanks Paul.

If you guys need me to test anything etc… just hit me up.