Closing a vision popup by pressing Esc

Hi,

How can I close a custom popup window by pressing Esc ?

On Buttons there is a property “Default Button” making it respond to an Enter pressed on the window, but how can I do a similar behavior with a cancel or close button when pressing Esc ?

Thanks for the help

We use the code below (as a client event script, triggering on the ESC key)

windows = system.gui.getOpenedWindows()

for window in windows:
	try:
		isPopUp = ((not window.startMaximized) and (window.closable))
		if (isPopUp and window.isSelected()):
			system.nav.closeWindow(window)
			break
	except:
		pass
1 Like

How do you do such a script ?
When you say a “client event script” is this a script you put in the Scripting/Project Library folder ?

No, here:

2 Likes

In V8 it was in a slightly different place but it is still quite similar to your printscreen:

It’s now working well. Thank you very much for your help !