visionWindowOpened Script Not Running

I have a script on a docked window's open event handler that doesn't seem to be running. The window is set to open on startup.

I have a logger set up for diagnostics as well, but none of the logging info is in the gateway status logs, which leads me to believe that the script isn't running for some reason.

logger set up in the Navigation script library:

#set up navigation logger
logger = system.util.getLogger('Navigation')

From the first line of the visionWindowOpened script on the docked window:

Navigation.logger.info('Nav Dock Opened.')

But I see no such entry in the log when I launch a client.

Logger statements don't automatically go to the gateway; you're just creating a logger in the local scope:

2 Likes

Also, why are you doing

Navigation.logger.info('Nav Dock Opened.')

your logger is bound to the variable logger, so wouldn't it be

logger.info('Nav Dock Opened.')
1 Like

logger exists in the scope of the Navigation script library

1 Like

So I created a logger in the scope of a script library. Where would it go, or how do I get it to the gateway status log? I didn't see a case for a script executing in the client scope.

The project script library doesn't have a scope. It's just a library. The scope of anything used there is the scope of the event that calls into that library.

Vision clients log locally, visible only in their local diagnostics (via the help menu). Same with the designer. Only code that runs in the gateway itself will log to the gateway logs.

Is there a keyboard shortcut to open that? I have it disabled

Ctrl + Shift + F7.

Alternately, for posterity:

3 Likes

How about opening on a button press?

edit: beat me to it :sweat_smile:

It would be nice if that page also stated what the keyboard shortcut is.

This topic doesn't mention the Vision client at all:

2 Likes

So, other than the logger not logging where expected, the script is running, but it's running too early?

The window open is supposed to fire a script that swaps to a window and updates a property on the docked window, but that property on the docked window is not updating

Yes, window open is documented to run before bindings run. It also doesn't run again if a window is cached and re-opened. it is almost never the "right" place to put anything.

Is this the window that auto-opens on project start? If so, make no window auto-open at all, and provide precise initial actions in a client startup event instead.

:upside_down_face: turns out my script only wrote one of the two properties I was expecting it to. We'll see if that fixes it :sweat_smile:

It works as expected after fixing the script