Passing scroll events from child repeater to parent canvas

To play around with this, I set up a template canvas where one of the templates had a template repeater that didn't need scrolling. This script produced the desired result from the nested template repeater's propertyChange event handler:

# Written for the propertyChange event handler of the TEMPLATE REPEATER
# Won't run in designer unless preview mode is on prior to opening the window
if event.propertyName == 'componentRunning':
	
	# Nested function that gets all components of a given class within a given container
	# Recommend relocating this to a library script because it is quite handy
	def getAllComponentsOfClass(container, className):
		foundComponents = []
		for component in container.components:
			if component.__class__.__name__ == className:
				foundComponents.append(component)
			else:
				foundComponents.extend(getAllComponentsOfClass(component, 'JideScrollPane'))
		return foundComponents
	
	# Get all of the JideScrollPanes in the source repeater
	scrollPanes = getAllComponentsOfClass(event.source, 'JideScrollPane')
	
	# Iterate through the scroll panes and remove all mouse listeners and mouse wheel listeners,
	# ...so a parent canvas's scroll wheel event is not consumed by these inner components
	for scrollPane in scrollPanes:
		for listener in scrollPane.mouseWheelListeners:
			scrollPane.removeMouseWheelListener(listener)
		for listener in scrollPane.mouseListeners:
			scrollPane.remove(listener)

At initialization, it simply locates all of the JideScrollPanes within a given repeater and removes the listeners that can consume a mouse wheel event.

4 Likes