# Using the Template Canvas as a work-around for Zoom

**URL:** <https://forum.inductiveautomation.com/t/using-the-template-canvas-as-a-work-around-for-zoom/42774>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [January 29, 2021, 10:55pm UTC](https://forum.inductiveautomation.com/t/using-the-template-canvas-as-a-work-around-for-zoom/42774 "2021-01-29T22:55:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdc5067](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pdc5067](https://forum.inductiveautomation.com/u/pdc5067)\
**Post date:** [January 29, 2021, 10:55pm UTC](https://forum.inductiveautomation.com/t/using-the-template-canvas-as-a-work-around-for-zoom/42774/1 "2021-01-29T22:55:53Z")

</div>

I am currently using the Template Canvas for displaying a template that is my system layout. I have a dropdown component with different zoom percentages, and an update button. If a user selects a different zoom percentage and then clicks the update button, the window will run a timer script which re-populates the data in the Template canvas’s “.templates” attribute.

This all works as intended, however, Id really like to have the Template Canvas “focus” on a specific area when I do this zoom update, by initializing where the scroll bars are at when I do the update. I figured I could do this by setting the x and y columns to something like -100, -200 respectively and the Template Canvas would update with the scroll bars set to -100 and -200 in from the corner of the template… Instead it just cuts off 100 off the left of my template and 200 off the top of my template.

Please let me know if anyone has a suggestion for this! Thanks!

---

<div class="post-metadata">

**Author:** ![pdc5067](https://avatars.discourse-cdn.com/v4/letter/p/c6cbf5/32.png) [@pdc5067](https://forum.inductiveautomation.com/u/pdc5067)\
**Post date:** [February 1, 2021, 11:13pm UTC](https://forum.inductiveautomation.com/t/using-the-template-canvas-as-a-work-around-for-zoom/42774/2 "2021-02-01T23:13:55Z")

</div>

I have noticed several forum posts on similar topics:

> [@Template Canvas set scrollbar position?](http://forum.inductiveautomation.com/t/template-canvas-set-scrollbar-position/15752):
>
> I have a number of templates in a template canvas, and depending on the active process I want to “jump” to the position of a specific template in the canvas when the window is opened. If you navigate away from a window that has the canvas, and back again the canvas scrollbar resets back to a 0 reference, trying to prevent the need for an operator to scroll through the canvas should they navigate to another screen. I’d like something like this on a window opened script: if template1 active: …

> [@Template Canvas Help](http://forum.inductiveautomation.com/t/template-canvas-help/30671):
>
> 7.8.5 Reaching out to anyone that might shed some light on my project. I currently have a custom SVG of a map that is set on a Template Canvas in which I am changing the map dimensions by way of a mouse scroll using the MouseWheelListener() in the event handler of the main screen using the internalFrameActivated. from javax.swing import SwingUtilities from javax.swing import JScrollPane from java.awt.event import MouseWheelEvent from java.awt.event import MouseWheelListener class DebugMouseWh…

> [@Scroll bar is slow](http://forum.inductiveautomation.com/t/scroll-bar-is-slow/5043):
>
> I have noticed if I make window’s height very tall so there is a scroll bar on the right when a user uses the mouse wheel to scroll the scroll bar barely moves. Is there a way to speed up the mouse wheel scroll on tall windows? Thank you,

> [@Scroll bar is slow for repeaters](http://forum.inductiveautomation.com/t/scroll-bar-is-slow-for-repeaters/9724):
>
> So there’s a post from 2012 regarding this exact issue. But here I am in 2015 with the same issue but for the scrollbar on my template repeater. The final suggestion was: [code] #increases scroll bar speed from javax.swing import SwingUtilities from javax.swing import JScrollPane scrollPane = SwingUtilities.getAncestorOfClass(JScrollPane, event.source) scrollPane.getVerticalScrollBar().setUnitIncrement(10)[/code] and my implementation: [code]#increases scroll bar speed from javax.swin…

But there has only been solutions to scrollbar incrementing. This is my solution to the "focus" or "Jump-to" issue....

```python
from java.awt import Point
def TemplateCanvas_Focus():
	canvas = event.source.parent.parent.getComponent("Template Canvas")
	#### this is the java JScrollPane class... we can use any methods associated with JScrollPane here####
	scrollPane = canvas.getComponents()[2]
	####this is the java JSViewport class... we can use any methods associated with JViewport here####
	viewPort = scrollPane.getViewport()	
	
	if event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == 'Full Screen':
		setViewPositionX = 0
		setViewPositionY = 0
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == '75%':
		setViewPositionX = 0
		setViewPositionY = 350
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == '100%':
		setViewPositionX = 250
		setViewPositionY = 500
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == '200%':
		setViewPositionX = 1000
		setViewPositionY = 1000
	elif event.source.parent.getComponent('Dropdown for Zoom').selectedLabel == 'Max Zoom':
		setViewPositionX = 1500
		setViewPositionY = 1500
	
	
	viewPort.setViewPosition(Point(setViewPositionX,setViewPositionY))

```

---

<div class="post-metadata">

**Author:** ![meredithj](https://avatars.discourse-cdn.com/v4/letter/m/cc9497/32.png) [@meredithj](https://forum.inductiveautomation.com/u/meredithj)\
**Post date:** [August 3, 2021, 12:50pm UTC](https://forum.inductiveautomation.com/t/using-the-template-canvas-as-a-work-around-for-zoom/42774/3 "2021-08-03T12:50:32Z")

</div>

I used the viewPostition method on Ignition 8 and I was having issues with getting it to work until I ran this in an invokeAsynchronous function.
