Swipe Touch Interface

We have a client wanting to do a large touch interface and have the user change screens and other functions using the swiping side to side and up and down motion. Any suggestions on how to accomplish this with an Ignition solution?


Add a the following Custom properties to the Object (ie: Root Container, label, etc…):
x1, y1

Add the following code to the mousePressed event:

# Get the starting x/y coords and store them for later.
x1 = event.getX()
y1 = event.getY()

event.source.x1 = x1
event.source.y1 = y1

Code for the mouseReleased event.

# Get the starting x/y coords from the press event.
x1 = event.source.x1
y1 = event.source.y1 

# Get the x/y coords from the release event.
x2 = event.getX()
y2 = event.getY()

# See which way they moved.
x3 = x1 - x2
y3 = y1 - y2

# Check to see if they moved minimum distance.
if abs(x3) > 10:
	if x3 > 0:
		system.gui.messageBox("You moved LEFT")
		system.gui.messageBox("You moved RIGHT")
elif abs(y3) > 10:
	if y3 > 0:
		system.gui.messageBox("You moved UP")
		system.gui.messageBox("You moved DOWN")

I made it it do messageBox popups, but you can change it to whatever you want.


1 Like

That’s pretty cool. I wonder how well it will work on a mobile application across the internet, thinking mobile phone app.


I use this with the mobile mobile for IPAD2 and android (Motorola Droid).
Works great. :smiling_imp:


在prespective怎样记录按键按下的值呢,event.source.x1 = x1prespective是不起作用的