# Swipe Touch Interface

**URL:** <https://forum.inductiveautomation.com/t/swipe-touch-interface/8833>\
**Category:** Ignition\
**Created:** [July 31, 2014, 6:44pm UTC](https://forum.inductiveautomation.com/t/swipe-touch-interface/8833 "2014-07-31T18:44:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Automator59](https://avatars.discourse-cdn.com/v4/letter/a/13edae/32.png) [@Automator59](https://forum.inductiveautomation.com/u/Automator59)\
**Post date:** [July 31, 2014, 6:44pm UTC](https://forum.inductiveautomation.com/t/swipe-touch-interface/8833/1 "2014-07-31T18:44:05Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [August 12, 2014, 3:12pm UTC](https://forum.inductiveautomation.com/t/swipe-touch-interface/8833/2 "2014-08-12T15:12:52Z")

</div>

Yes.

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

Add the following code to the mousePressed event:

```auto
# 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.

```auto
# 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")
	else:
		system.gui.messageBox("You moved RIGHT")
elif abs(y3) > 10:
	if y3 > 0:
		system.gui.messageBox("You moved UP")
	else:
		system.gui.messageBox("You moved DOWN")
```

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

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![Pat](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Pat](https://forum.inductiveautomation.com/u/Pat)\
**Post date:** [August 12, 2014, 7:14pm UTC](https://forum.inductiveautomation.com/t/swipe-touch-interface/8833/3 "2014-08-12T19:14:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [August 12, 2014, 9:54pm UTC](https://forum.inductiveautomation.com/t/swipe-touch-interface/8833/4 "2014-08-12T21:54:40Z")

</div>

Pat-

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

Cheers,  
Chris

---

<div class="post-metadata">

**Author:** ![448719222](https://avatars.discourse-cdn.com/v4/letter/4/71e660/32.png) [@448719222](https://forum.inductiveautomation.com/u/448719222)\
**Post date:** [November 20, 2020, 1:48am UTC](https://forum.inductiveautomation.com/t/swipe-touch-interface/8833/5 "2020-11-20T01:48:42Z")

</div>

> [@CPowell](#):
>
> event.source.x1

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