Register multi-touch as a single touch? - ios

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.

Related

Detect palm touching/releasing the iphone screen

Implementing a sort of 'distress call' button which should work as following:
User starts application and covers a screen with a palm of a hand
Some time passes, user may introduce additional touches during that time or remove some of the existing (but not all of them), location/shape of touches may change
When user releases a hand (i.e. removes last touch) a distress signal is emitted by the app
Basically, the app should register two events: (1) a screen is touched (2) all touched are released
I'm trying to use touchesBegan/touchesEnded methods and those work for small area touches (fingertips) but on touching screen with a full palm or even only palm edge a touchesCancelled gets triggered immediately while hand is still on the screen. Obviously no other events are emitted upon hand release afterwards.
I tried subclassing UIWindow and UIApplication and overriding sendEvent in those but got no additional info - large area touches are triggering touch begin and immediately touch cancel, releasing hand afterwards emits nothing. In some cases large area touches fire no events at all, not even the touchesBegan. Basically, iOS doesn't let me work with a very basic scenario - detecting just the fact of screen touch/release.
Is there any way to query the screen touch state directly and not work with responder chain? Or suppress the cancellation event from firing? Or maybe I'm missing something?
Unfortunately, as of right now, no solution exists

How can I "mock" the UI of an iOS app?

I am trying to take screenshots of my iOS app. Before taking a screenshot, I need to get the app to an appropriate state. To get to an appropriate state, a lot of swiping is required.
This would have been fine if I have actual devices, but I don't. So I need to perform swipes on a simulator using a trackpad. I find this very hard, and sometimes I can't swipe properly so the gesture is not recognised.
I thought of using the UI Testing library to programmatically perform swipes. However, my app is actually a game, and random events happen. Writing code to handle these random events would not be worth the time. It would be best if I am in control of the swiping.
I have also thought of adding buttons on the UI of the app. When they are pressed a swipe is simulated. Then I can just click those buttons instead of swiping with my trackpad, which is way easier. However, these buttons will then appear on the screenshot, which I obviously don't want users to see.
Also note that I can't use a tap gesture recogniser as a replacement for the swipe gesture recognisers, because I need to detect swipes in all four directions and do different things depending on the direction.
Essentially, how can I perform a "swipe" more easily on the simulator? It would be great if I can do this by pressing keys on my keyboard, or maybe there is a feature in Xcode that allows me to do this which I am not aware of?
I suggest you automate the UI test.
Recording a test from live actions is a standard Xcode UI test feature. Fastlane is the icing on the cake to automate the capture of screenshots too.
Fastlane has the tools to automatically run a UI test and capture screenshots in all device resolutions. You can even record the actions by recording a UI test and play it back.
Check it out here:
Fastlane Screenshot
Even if you do not wish to use Fastlane, you can record the gestures in a unit test and have it pause.

Xcode 7 UI Testing not recording swipes

I have a collection view in my app, which is inside a table view cell (yes I know it's weird), and I want to UI Test the scrolling of the collection view. I use the recording button for this, however Xcode identifies the swiping on my collection view as taps. If I manually change the generated UI Test code from [collectionview tap] to [collectionview scrollLeft], it works, but Xcode won't generate the code for swiping automatically.
What could be the problem?
Xcode only recognises a gesture as a swipe if your trajectory with the gesture is fast, straight and true to the (up/down/left/right) direction you are swiping in.
My guess is that this prevents recording drag or tap-and-hold gestures as swipes, since these are unsupported by the recording tool. If you were going for either of those, a tap gesture would be closer.
As a workaround, take note of where you expected a swipe and switch the gesture as you have been doing when your swipes aren't recorded.
I believe you should file a bug with Apple and include a sample project.
It may be hard for the recording system to differentiate between a tap, a long press, and a swipe. While I've seen the recording of tap events to be reliable, I find I'm manually typing any steps for swipes or typeText. Generally I use the UI test recording feature to help with identification of particular elements, which I then work with in code to specify the user interactions and asserts.
If you want to create a sample project on github or somewhere with your collectionView-inside-tableViewCell configuration, I'd be willing to take a look.
EDIT: After trying your example project, I was sometimes able to get Xcode to record swipeLeft and swipeRight events from the first cell. It's not the most elegant approach, but with the trackpad on my MacBook Air, I start a horizontal swipe with one finger without pressing the mouse button, and then press the button with another finger while the first finger is still swiping.
There were some instances when Xcode recorded this simply as a tap, and at least one instance where it recorded a twoFingerTap.

Delphi - Simulate Click Animation

This is my first post here on stackoverflow so forgive me for anything I'm doing wrong.
I'm making a kind of guide to the users without any computer knowledge of my application where I show him how to use it by signalizing what he should do, more specifically where to click. I want to that by moving a "fake" cursor to the button and simulate a click, and here is where I got my problem, I have to simulate just the animation of the click, and not the event itself but I couldn't find a way to do that, can anyone help me?
What you're describing is exactly what WH_JOURNALPLAYBACK is for. It populates the message queue with the mouse and keyboard messages you want to occur, and the OS interprets them. In your case, activate the playback hook and perform the mouse events necessary for performing a click.
In preparation, you'll probably want to use WH_JOURNALRECORD to discover what messages you need. Once you have them, you can probably winnow them down to a reasonably sized list prior to shipping your product to customers. (In particualr, you'll probably record many more mouse-move messages than you really need.)
In your button's click handler, check whether playback is active. Only perform the rest of the event handler when playback isn't active. That way, your program will behave just as though the button were clicked (including any animation), but it won't execute the real event code.

Neither touchUpInside nor toutchUpOutside is called on palm press/lift over several buttons

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.

Resources