Alarm status table: scrollbar width and return to top in marquee mode [vision]

Hi guys, I have a couple of question about the Alarm Status Table in Vision.

I have a touchscreen where I show the main alarms of the plants.. The questions are:

  1. How can I change the size of the vertical scrollbar (with the touch is quite difficult to move it)
  2. I set the Alarm Table in marquee mode but I would like to disable it when I have new alarms active; this is not a problem, I can manage it, but I don't know how I can return to the top, because as soon as I disable the marquee mode it freezes in the row without moving the view to the top.

Thanks for the help.

I was able to accomplish this from a button on my alarm status table using the following code:

from java.awt import Dimension
scrollPane = event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0)
scrollPane.getVerticalScrollBar().setPreferredSize(Dimension(100, 0))

The code gets the scroll pane and directly sets the preferred width of the vertical scroll bar.
Here is the result:
image

This button actionPerformed script works on my alarm status table:

from java.awt import Point
viewPort = event.source.parent.getComponent('Alarm Status Table').getComponent(0).getComponent(0).getComponent(1).getComponent(0).getComponent(0)
viewPort.setViewPosition(Point(0,0))

It gets the viewport and sets the position to zero.

Thank you very much for your help, this is exactly what I need.

May I ask you could I know how all the .getComponent(index) works?

Most components are actually a groups of nested components. If you take a component and use the method getComponents(), a list of subcomponents will be returned. To get a specific subcomponent in the list an index can be specified: either .getComponents()[index] or simply getComponent(index)
To find a type of component in this way, it is possible to drill down level by level using something like:

for subComponent in component.getComponents():
	print type(subComponent)

There's a 'Scrollbar Width' property where you enable touchscreen mode in the project properties:
https://docs.inductiveautomation.com/display/DOC81/Vision+Project+Properties#VisionProjectProperties-VisionGeneralProperties

1 Like

Extending this, here's what I used to use in Vision to see what all the components in IA components are:

# traverse all components within an object and print them and their component index reference to the screen
def printAllObjectComponents(object, indexPrefix = '', indent = ''):
	components = object.getComponents()
	for index, component in enumerate(components):
		print "%s %s%s %s" % (indent, indexPrefix, index, component)
		
		printAllObjectComponents(component, indexPrefix + str(index) + '.', indent + '\t')
3 Likes

Very nice! I like how the output is tabbed to illustrate the nesting level.