The title says it all. I have both events registered for the same object. It is meant to differentiate a drag from a tap, but when TOUCH_END fires, so does TOUCH_TAP. This represents a problem if my program cannot differentiate between the two. I have tried unregistering the TOUCH_TAP handler inside of TOUCH_BEGIN and reregistering for TOUCH_END but that doesn't seem to solve the problem.
How can I differentiate between a drag and a tap? My target SDK is AIR 4.0 for iOS.
Related
Is there a way to register multi-touch as a single touch? Say if I use three fingers to tap a large button, can it be registered as simply one tap of the button? -- the current default appears to treat it as a multi-touch, and as a result ignores the button-pressing altogether. Similarly, if I use my palm to tap a large button, the button isn't pressed either.
I noticed in iphone Accessibility Settings -> Touch Accommodations, one could set "Ignore Repeat" and "Use Initial Touch Location" for tap assistance. Of course, if those are turned on, it affects the entire phone instead of just one app. But would that be the direction to approach this problem?
BTW I don't actually need multi-touch in my app. So if turning off multi-touch can be more simply done on the whole-app level instead of button-by-button, it would suit this case very well.
Thank you #DonMag for providing a hint.
So, if yours is an ios app from Capacitor, here is how to change your javascript code:
Change your button onClick events into "onTouchStart"
Use a state variable to keep track of whether "onTouchStart" is triggered and the resulting logic is executing. During that execution, prevent more touch events to have further effect on the button. This is to prevent the button from being pressed in quick succession by multiple touches that come from, say, your three-finger tap or palm tap. Only after the execution is finished do you revert the state variable back to the original value, so that the button is ready to be pressed again.
If there is an answer that's more suitable for the native Swift bundle I'll accept that as the answer. The above is just to help anyone who may encounter the same problem as mine.
one thing I observed in iOS 9.0 is that when I tap on button or TableView, canPerformMethod:withSender: method is called with sender as UIButton type. I am using this method to prepare my customized option menu.
I did not observed that in previous iOS. Can anyone see me API changes, because I went through overall changes of iOS, but I did not find above mentioned changes in change log or change history.
Per Apple Documentation,
iOS 3.0 introduced system capabilities for generating motion events,
specifically the motion of shaking the device. The event-handling
methods for these kinds of events are motionBegan:withEvent:,
motionEnded:withEvent:, and motionCancelled:withEvent:. Additionally
for iOS 3.0, the canPerformAction:withSender: method allows responders
to validate commands in the user interface while the undoManager
property returns the nearest NSUndoManager object in the responder
chain.
So, all the UIResponder sub classes are entitled to receive a call back for canPerformAction:withSender:. You should use sender parameter to do the handling in this method.
I have an app with an app with a UIScrollView. I am letting IOS handle all the I/O (i.e., no gesture recognizers).
I have a cat that likes playing on the iPad and she is able to manipulate the scrollview in such a way that it gets the error in the title.
I have seen this mentioned in other posts where there were PinchGestureRecognizer.
What would be causing this in the absence of one?
What does it mean?
I don't know what the cat does to cause this. She can do it nearly on demand. I can't do it at all.
Switch off Multitasking Gestures. This can be done in the Settings panel.
iOS 7 adds support for gestures which allow you to control audio or consult the calendar. You do not need to add gesture recognizers of your own; the OS brings them in all by itself. They also cannot be disabled from within the app.
Now for what I suspect is the reason for the messages: It seems your cat is sending so many touch events to the touch recognizer that it is overloaded. This is in essence what the error message means. It could not process all touch events in a timely manner. After all, a cat has four paws ...
On Mac, one can always get the location of the mouse "outside the event stream" (ie, even if you've not subscribed to any delegate methods for mouseUp: et al) by calling [NSEvent mouseLocation].
Is there any way on iOS to get current touch events without listening to touchesBegan:?
I ask because there is at least one situation in which touchesBegan is not called: at app launch, if a touch is already in progress, touchesBegan is never called. In fact, neither are any of the touch-related UIEvent methods called as near as I can tell (nor UIApplication's / UIWindow's sendEvent:, apparently).
I would like to vary the behavior of my app slightly based on whether a touch is in progress at launch. Is there any way to detect an in-progress touch at app launch?
This cannot be done. The simple reason: The touch events don't belong to your app. Each touch belongs to some UI element (or responder). As you already know, this element gets the began, moved, ended, cancelled messages.
This is even true within a properly programmed app: All events regarding one touch are delivered to the very same object. After all, how would another object know what to do with that event, and how should the first object properly finish its expected behavior?
While you can (or could, but probably shouldn't) find a work around within your app, there's just no way for cross-app-touch passings.
And on the Mac you may query the mouse position, but in normal application flow there'll always be a mouse down before you get a mouse up event.
To be honest, I don't see any reason why this would be needed anyway... oh wait... I could split my app icon into several areas... not sure if it would already break privacy laws, though, if you get to know where the user has his icon on screen.
I think you could simply "extend" the application launch. When I had time consuming tasks during my application launch, I used to show the same splash screen with a UIActivityIndicator while the action was being carried out.
You could simply create a NSTimer, wait for about 2 seconds and during this time, check for touches, while the splash screen will still be showing.
To do this, in applicationDidFinishLaunch, push a ViewController that looks exactaly like the splash screen and check for touches in this ViewController. After those 2 seconds, proceed with normal initialisation. This behaviour also helps if you have time consuming tasks during initialisation.
I know, it`s a workaround, but my guess, is that it is not possible to check for touches because application will be working on the main thread and the touches also processes on the main thread. This could happen also because there are no ViewControllers or UIWindow initialised and ready to listen to touches.
Hope it helps.
You might try handling the hitTest:withEvent: instead.
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event;
Since according to apple doc "Returns the farthest descendant of the receiver in the view hierarchy (including itself) that contains a specified point."
I am implementing an IOS APP with a view that provides a keypad for controlling a remote device and if you push on 6 or 8 (UI) buttons at the same time by using your palm then the App gets a touchDown but does not receive a touchUpInside or touchUpOutside when you lift the palm.
Problem is I start a timer upon the touchDown to repeat keys, but I never get a callback to end key repeats. Does anybody know how to deal with this.
I realize this is an anal scenario, but if repeats don't stop on time then expensive equipment could be damaged.
I am not sure this has any bearing on the situation but I am using ios 6 on an iPhone 5.
Is touching them at the same time also a requirement? If not, set exclusiveTouch to YES on all buttons. If yes, check UIControlEventTouchCancel as well.