Questions tagged [touch-event]

An event that is triggered when a user 'touches' a GUI component

A TouchEvent is an event that is triggered when a user 'touches' a GUI component. This is most commonly associated with applications that are designed to run on smart phones and touch screens. Many programming languages will treat an TouchEvent the same as a MouseEvent, which helps to provide touch functionality to applications that haven't specifically been designed for touch interactions.

1935 questions
198
votes
9 answers

how to programmatically fake a touch event to a UIButton?

I'm writing some unit tests and, because of the nature of this particular app, it's important that I get as high up the UI chain as possible. So, what I'd like to do is programmatically trigger a button-press, as if the user had pressed the button…
Olie
  • 24,597
  • 18
  • 99
  • 131
106
votes
4 answers

Handling Touch Event in UILabel and hooking it up to an IBAction

Ok, so I have a UILabel created in interface builder that displays some some default text of "tap to begin". When the user taps the UILabel I want it to trigger an IBAction method: -(IBAction)next; which updates the text on the label to say…
wfbarksdale
  • 7,498
  • 15
  • 65
  • 88
84
votes
11 answers

How to distinguish between move and click in onTouchEvent()?

In my application, I need to handle both move and click events. A click is a sequence of one ACTION_DOWN action, several ACTION_MOVE actions and one ACTION_UP action. In theory, if you get an ACTION_DOWN event and then an ACTION_UP event - it means…
some.birdie
  • 2,259
  • 4
  • 24
  • 28
64
votes
7 answers

onTouchevent() vs onTouch()

After many experiments with onTouchEvent and onTouch, I found that onTouch works everywhere you want (whether it is in activity or view) as long as you have declared the interface and put the Listener right! On the other hand, onTouchEvent only…
stelios
  • 1,027
  • 3
  • 14
  • 19
61
votes
2 answers

How to handle Touch Events on a Fragment?

I'm building an interface where I need to process touch events. In particular I would to be able to enable them only to a confined area in a fragment. To better understand the problem, to respect the standards and for the goal of my application, I…
user3319400
  • 823
  • 2
  • 7
  • 10
59
votes
15 answers

Disable the touch events for all the views

What's the best way to disable the touch events for all the views?
Gratzi
  • 4,633
  • 12
  • 42
  • 58
58
votes
6 answers

Using BottomSheetBehavior with a inner CoordinatorLayout

The design support library v. 23.2 introduced BottomSheetBehavior, which allows childs of a coordinator to act as bottom sheets (views draggable from the bottom of the screen). What I’d like to do is to have, as a bottom sheet view, the following…
56
votes
3 answers

Pass touches to the view under

In my app I have a fragment on top of the activity. The fragment is filling the whole screen. Part of the fragment is a transparent View and you can see the views under (that belong to the activity). Is there a way to transfer the touch events to…
roiberg
  • 13,629
  • 12
  • 60
  • 91
51
votes
2 answers

touchend event properties

If I catch all touchend events from mobile devices with: $(document.body).bind('touchend', function (e) { var touch = e.touches[0]; // doesnt work ... I need to get the touch.screenX, touch.screenY, touch.clientX and touch.clientX from the e…
Matt Roberts
  • 26,371
  • 31
  • 103
  • 180
50
votes
4 answers

What is the difference between the click and tap events?

I am developing an app that runs on Android/iOS and desktop computers. Should I use the click or the tap event? What are the differences between them? Will the 'tap' work on desktop? if not, (and I have to use click) am I missing any advantages that…
Tiger
  • 569
  • 1
  • 5
  • 8
49
votes
12 answers

prevent touchstart when swiping

I have a scrollable list on a mobile device. They want people to be able to scroll the list via swiping, and also select a row by tapping. The catch is combining the two. I don't want a row to be selected if you are actually scrolling the list.…
DA.
  • 39,848
  • 49
  • 150
  • 213
42
votes
2 answers

Can't get coordinates of touchevents in Javascript on Android devices

I'm testing the HTML5 canvas and using Javascript to draw for touch enabled devices. While I have it working in iOS devices I cannot get it to work on Android. I have narrowed it down to event.pageX not returning the coordinates, but instead either…
Stuart Lacy
  • 1,963
  • 2
  • 18
  • 30
39
votes
4 answers

checking if touchend comes after a drag

I have some code which changes the class of a table. On a phone, sometimes the table will be too wide for the screen and the user will drag/scroll about to see the contents. However, when they touch and drag the table around, it triggers touchend on…
Konrad Lawson
  • 559
  • 1
  • 4
  • 10
37
votes
4 answers

Method onTouchEvent not being called

I'm having a problem that my method @Override public boolean onTouchEvent(MotionEvent event) { return gestureDetector.onTouchEvent(event); } is never called. Any ideas why is that so? I'm building a google's API 4.0.3 application, and I'm…
gabrjan
  • 3,080
  • 9
  • 40
  • 69
36
votes
2 answers

How to add a gesture detector to a view in Android

I was struggling with adding a gesture detector to a subview in my project. Do I override the parent's onTouchEvent or the child's onTouchEvent? Do I make an OnTouchListener and add the gesture detector there? The documentation shows an example for…
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
1
2 3
99 100