Is there a way to allow mouse clicks to pass to object beneath

You could do a hit-test in the OnMouseClicked event of your overlaying component.

I was able to implement this with custom methods named “clicked” on various vision components. A semi-transparent rectangle overlays all the components and performs the hit-tests.

Here’s the hit-test code:

from com.inductiveautomation.vision.api.client.components.shapes import PathBasedVisionShape

for comp in event.source.parent.getComponents():
	if comp == event.source:
		continue
	if isinstance(comp, PathBasedVisionShape):
		if comp.getBoundingRect().contains(event.point):
			comp.clicked()
	else:
		if comp.bounds.contains(event.point):
			comp.clicked()

It’s necessary to perform the type check before the hit-test because only shapes have the getBoundingRect() method. Curiously, the bounds property of vision shapes doesn’t store the actual layout information. For most standard vision/swing components, component.bounds works fine.

2 Likes