Looking for a way to modify the size of the scrollbar for Alarm Journal component, without touchscreen mode enabled. Was able to find a topic somewhere that spelled out how to change the size of the alarm status table via scripting, trying to achieve the same thing for the Alarm Journal table.
I can drill down into the components of the Alarm Journal table but I’m not exactly sure how to implement the methods to modify them as I’m not very Java savvy.
I remember that one. Rather than developing individual scripts for every component in Vision, I imagine it would be better to simply make a generic script for modifying vertical scroll bars that will work on any given component.
Here's an example of a script that could be tossed into the project library and used for any component that requires vertical scrollbar width adjustment:
# Function to set all vertical scrollbars within a given component to a given width
def setVerticalScrollbarWidths(component, width):
# Check to see if the given component has a vertical scroll bar
if hasattr(component, 'verticalScrollBar'):
# Simply modify the existing preferred size using the given width and set it back to the scrollbar
# (This could also done by importing Dimension at top level and creating a new one using the existing preferred height with the given width)
verticalScrollBar = component.verticalScrollBar
preferredSize = verticalScrollBar.getPreferredSize()
preferredSize.width = width
verticalScrollBar.setPreferredSize(preferredSize)
verticalScrollBar.revalidate() # Has to be done to make the change visibly take effect instantly
# Recursively pass all subcomponents back into the function to check them for vertical scroll bars
for subComponent in component.components:
setVerticalScrollbarWidths(subComponent, width)
If the function were added to library script called components:
...then it could be called during the journal table's initialization from the journal table's propertyChange event handler in this way:
# Runs only once at initialization
# Will NOT run in the designer UNLESS preview mode is started prior to opening the window
if event.propertyName == 'componentRunning' and event.newValue:
# Set the width in pixels of the vertical scrollbars at initialization
component = event.source
width = 40
scriptLibrary.components.setVerticalScrollbarWidths(component, width)
To make this work in the designer without requiring opening in preview mode, I tend to place such initialization on an integer custom property expression binding, like so:
And I alter the function to return a random integer so you can see it working.
(If you cannot use my Integration Toolkit's objectScript(), you can also put the above in a component custom method, and call runScript() on it instead.)
An expression binding on a boolean property using the systemFlags client tag can also be used for things that are lost when preview mode is stopped. I use this binding on the visibility property of overlays to keep them out of the way while I'm designing.
This worked perfectly, makes me feel silly how easy you made this look. Much easier than trying to figure out how to drill into the components 1 by 1.
Thank you a bunch, made my life a lot easier. I’ve seen pturmel up and down these forums but not you. Appreciate both of your contributions on these forums, a lot of questions I’ve had were already asked and solved by smarter individuals on these forums including you two.