Any way to toggle visibility of a Shared Docked View?

Is there any way to toggle a shared docked view at the start-up of a perspective session?

I want to hide or show a banner based off of a tag value–and it needs to be across the whole session once it starts up. (I tried system.perspective.closeDock() within a session startup script but that didn’t work because a page wasn’t attached to the thread.) But I don’t have a specific page b/c it’s a shared view–it’s on all pages.

1 Like

You’ll most likely need to use message handling. On the dock, have a message handler that opens/closes itself based on the message it receives. Make sure you get the right scope.

1 Like

I don’t see a way for docks to handle messages.
I know I could handle a message in each view I make, but I would like to be able to set it in one place since it is a shared dock on all pages.

A shared dock is always “open” in memory, you just hide and show it when you need to.

Then just use sendMessage to open or hide it:

system.perspective.sendMessage('toggle-test-dock', False, 'session') # hide it
system.perspective.sendMessage('toggle-test-dock', True, 'session') # show it
1 Like

Right, but this approach requires that I add this script to every single view I make, correct?

I’m looking for a global way to handle this, where I only make a change in one spot. That way I don’t have to manage duplicate code and remember to add that code to ever new view we create.

Well, you need to add the message handler to every single shared dock you create that you want to be able to show or hide from a tag, but I daresay you’ll only have a few of these. You should be able to call those single-line sendMessage functions from anywhere, page or tag/session prop. So unless that’s duplicating code (reusing library functions), it should get you what you need, no?

Note: if using within a tag, you’ll need to use the gateway version:
https://docs.inductiveautomation.com/display/DOC81/system.util.sendMessage

Right but where do I call the “sendMessage” function?
Calling it at session startup does not work. (perhaps because the dock hasn’t yet loaded on start up so it misses the message).

I can send the message and successfully hide the view when a page gets started up, but then I have to send the message on the start up of every page. Which goes back to having to manage startup scripts for every view created.

Have your dock send itself the message, too, on its startup.

That was an intriguing suggestion. I tried it out and unfortunately once I navigate to a new page the docked view comes right back up. (I guess shared views only start up once, not after every page load.)

So I’d still need to send the message on the startup of every page.

There isn’t some sort of “message” banner or other component that I’m not aware of, is there?

That’s kind of ideal for what I want. (e.g. when a website is being updated or a server is down, a banner will appear at the top of the webpage.)

No, but that's an interesting idea...

1 Like