Using a docked view for an alarm banner. Would be nice to be able to draw attention to the docked view when it's hidden by changing/animating the icon in the handle.
Has anybody done this? Is it possible?
Using a docked view for an alarm banner. Would be nice to be able to draw attention to the docked view when it's hidden by changing/animating the icon in the handle.
Has anybody done this? Is it possible?
It requires 8.1.19 or newer: system.perspective.alterDock - Ignition User Manual 8.1 - Ignition Documentation
If you're looking to modify the color of the icon, you'll need 8.1.22 or newer, and you'll need to setup your own css rule to "animate" the color swapping:
Trying to modify the handle and visibility using this function. I update the properties like so from a button script on the docked view.
def runAction(self, event):
if (self.session.custom.dock_behavior == 'auto'):
#change to manual
system.perspective.alterDock('nav', {'handle':'show', 'display':'visible'} )
self.session.custom.dock_behavior = 'manual'
else:
#change to auto
system.perspective.alterDock('nav', {'handle':'autoHide', 'display':'onDemand'} )
self.session.custom.dock_behavior = 'auto'
It doesn't seem to update the behavior of the docked view.
The button's text is bound to the custom session prop, so I know the script is firing, but the docked view still acts like it's using onDemand after it's in manual mode. I've tested the settings for manual vs auto mode separately by changing them in the page configuration.
Do I need to close and reopen the docked view after calling alter?
Do I need to close the docked view, then call alter, then reopen?
I don't believe changing the display
setting actually forces the Docked View to immediately become visible, because you can configure multiple Docked Views on a side to be visible, but you'd still only ever show one at a time and we can't just assume the one you've now set to be visible is the one you want displayed. If your goal is to force the display of the "nav" Docked View, you'll probably need to include a call to system.perspective.openDock(id="nav")
Changing the display
property changes HOW the Docked View displays, not its current display state.
The purpose here is to allow a user on a smaller screen, say a tablet, have the docked view (navigation) auto-hide so it doesn't cover the content. However, on wider displays, say a desktop, to always have the docked view open because they have extra space and it doesn't actually cover any content due to the forced aspect ratio (4:3) of the content.
Calling openDock doesn't seem to do the trick. Same behavior.
if (self.session.custom.dock_behavior == 'auto'):
#change to manual
system.perspective.alterDock('nav', {'handle':'show', 'display':'visible'} )
self.session.custom.dock_behavior = 'manual'
else:
#change to auto
system.perspective.alterDock('nav', {'handle':'autoHide', 'display':'onDemand'} )
self.session.custom.dock_behavior = 'auto'
system.perspective.openDock('nav')
Where does this script live?
On a button in the docked view.
Odd. I just tried it and it worked.
target_dock_id = "re"
if (self.custom.dock_strategy == 'auto'):
#change to manual
system.perspective.alterDock(target_dock_id, {'handle':'show', 'display':'visible'} )
self.custom.dock_strategy = 'manual'
else:
#change to auto
system.perspective.alterDock(target_dock_id, {'handle':'autoHide', 'display':'onDemand'} )
self.custom.dock_strategy = 'auto'
system.perspective.openDock(target_dock_id)
In my script I changed the dock_behavior
prop to a custom property of the button - but that shouldn't affect anything. Check your logs to see if you're encountering any errors before the openDock
call.
Nothing in my Gateway log or Console log
Make sure you've saved your changes. I won't be able to get back to this until much later today or maybe even tomorrow.
Yep, changes saved. Even created a custom prop on the button and copy-pasted your code. Still not working for me. Ignition 8.1.23
Where do print calls from a Perspective script go? I don't see anything in the console:
def runAction(self, event):
target_dock_id = "nav"
print(target_dock_id)
auto_dock_props = {'handle':'autoHide', 'display':'onDemand'}
manual_dock_props = {'handle':'show', 'display':'visible'}
if (self.custom.dock_strategy == 'auto'):
#change to manual
print manual_dock_props
system.perspective.alterDock(target_dock_id, manual_dock_props)
self.custom.dock_strategy = 'manual'
else:
#change to auto
print auto_dock_props
system.perspective.alterDock(target_dock_id, auto_dock_props)
self.custom.dock_strategy = 'auto'
system.perspective.openDock(target_dock_id)
print("reopen dock")
Python print
calls go to the wrapper logs I believe (not positive). If you want something logged to the console, use system.perspective.print()
My script is definitely running, but I don't know why it's not altering the dock.
Ignition 8.1.23
Perspective 2.1.23
def runAction(self, event):
system.perspective.print("dock method was " + self.custom.dock_strategy )
system.perspective.print("")
target_dock_id = "nav"
auto_dock_props = {'handle':'autoHide', 'display':'onDemand'}
manual_dock_props = {'handle':'show', 'display':'visible'}
if (self.custom.dock_strategy == 'auto'):
target_dock_props = manual_dock_props;
self.custom.dock_strategy = 'manual'
else:
target_dock_props = auto_dock_props
self.custom.dock_strategy = 'auto'
system.perspective.print(target_dock_id)
system.perspective.print(target_dock_props)
system.perspective.alterDock(target_dock_id, target_dock_props)
system.perspective.openDock(target_dock_id)
system.perspective.print("")
system.perspective.print("reopen dock")
system.perspective.print("")
system.perspective.print("dock method is now " + self.custom.dock_strategy )
dock settings:
Could I get some insight into the Docked View settings for the Page Configuration? Do you have multiple Docked Views assigned to that side of the Page? Is there any chance you have more than one Docked View with an ID of "nav" for the Page Configuration (even on other sides)?
I have two docked views. One on the north and one on the west. North is for alarms. West is for navigation.
North:
West:
Corner priority is left-right
Okay, I'll try to replicate with all of this new information sometime today.
Were you able to replicate the issue?
I just tried myself (sorry - I've been swamped) using your exact configurations, and it's working for me.
What is not updating for you? My handle is changing state as expected. I did notice an odd-but-expected behavior where the handle can still be seen while "hidden" in its onDemand state, but that's a side-effect of the Docked View having no backgroundColor assigned - you can see through the Docked View to where the handle has gone to "hide".
The dock still auto-closes when I navigate to a different view, even after running the script to alter the dock.
For example, I'll try navigating between my Admin and Reports pages:
When the dock is set to visible (via page configuration), using the navigation buttons does not close the navigation bar (as expected):
But, when I change it to onDemand (again, via page configuration), using the navigation buttons closes the navigation bar (again, as expected):
That all works, but when changing these properties via script on the view the behavior is not updating. I want the docked view to start onDemand and change to visible if the user changes the setting with the button.
dock_behavior
- it can have values of "auto" or "manual" (auto by default)dock_strategy
- it is bidirectionally bound to the session prop"Dock : "+{session.custom.dock_behavior}
onActionPerformed
script checks the current dock_strategy
, switches the dock strategy and updates the custom view propdef runAction(self, event):
target_dock_id = 'nav'
auto_dock_props = {'handle':'autoHide', 'display':'onDemand'}
manual_dock_props = {'handle':'show', 'display':'visible'}
#current strategy is onDemand (auto) - change to visible (manual)
if (self.custom.dock_strategy == 'auto'):
target_dock_props = manual_dock_props;
self.custom.dock_strategy = 'manual'
#current strategy is visible (manual) - change to onDemand (auto)
else:
target_dock_props = auto_dock_props
self.custom.dock_strategy = 'auto'
system.perspective.alterDock(target_dock_id, target_dock_props)
system.perspective.openDock(id=target_dock_id)
Is there any way to get/read the dock properties directly?
I did notice something just now while I was messing with this. It seems like the handle's behavior might be updating, but the dock itself is not. If I change manual_dock_props
to hide the handle, instead of show it, the handle does show/autoHide on the button press. However, with the handle on the page configuration set to autoHide, if the handle is hidden (after the button press), and I navigate to a different view the handle comes back.