Vision info, error, message dosen't respect the desktop in some case

Ignition 8.1.10 - VISION
I have a support ticket (messageBox doesn’t respect desktop (IGN-2614 or #9019)) since few month for the following issue:

messageBox is always opened on the primary desktop when the following code:

desktop = "secondary"
system.gui.desktop(desktop).messageBox("message","title")

is called in an asychronous/later function.

I use this pattern when the user call long process, and I need to show a message when the process is ended.

I’m looking for a workaround to move the messageBox on the right desktop in my use case ?
Swing :mage:

Im guessing not all the monitors have the same names… so this?

from java.awt import GraphicsEnvironment

graphE = GraphicsEnvironment.getLocalGraphicsEnvironment();
screens = graphE.getScreenDevices();
desktops = []
for screen in screens :
	desktops.append(screen.getIDstring())

system.gui.desktop(desktops[1]).messageBox("message","title")

Or are they called “secondary” and it is a bug with the system.gui.desktop()?

desktop are in my case “primary” and “secondary”.
It’s a bug in system.gui.desktop("…").messageBox(“message”,“title”) ited to the calling context

You could bypass system.gui entirely and directly use ErrorUtil. Any of the overloads that accept a Component first argument can be provided any arbitrary JComponent - in theory, providing a component/window/etc would tell Swing to open it on the correct monitor.

You could even bypass ErrorUtil and directly call JOptionPane methods yourself:
https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/javax/swing/JOptionPane.html#showConfirmDialog(java.awt.Component,java.lang.Object)

Thanks,

when I try on a buuton:

from com.inductiveautomation.ignition.client.util.gui import ErrorUtil
msg = "message"
title = "titre"
parent = event.source.parent.parent.parent.parent
error = ErrorUtil()
error.showInfo​(parent,msg,title)

I have the following error:

TypeError: No visible constructors for class (com.inductiveautomation.ignition.client.util.gui.ErrorUtil)

It’s a static method, so you’d use it as:

ErrorUtil.showInfo​(parent, msg, title)

When I try it, I have an error ???

same error with

ErrorUtil.showInfo​(msg,title)

image
Weird, the forum inserted a special character.

Try this:
ErrorUtil.showInfo(parent, msg, title)
Or just type it out yourself after deleting that line, I guess.

1 Like

I wouldn’t expect it to be safe to run .messageBox() and friends from a background thread. Consider opening a popup at the start, hiding it, then updating it via invokeLater().

1 Like

weird, even if I provide the Jframe of the secondary desktop as component parameter,
error.showInfo​(parent,msg,title) open a box on the primary desktop when invoked from invoke later in an invoke asynchronous…

Yeah, I figured that might happen. This might be an outright Swing bug, not something wrong with our code. It might still be possible to work around it, but it’s going to get a lot harder.

1 Like