Highlight continues when touch outside of button in swift - ios

My question is that i have a UIButton inside my app. When touch it and move my finger outside of button, highlighting continues to specific points around it and then returns back to normal.
My expectation is that when i go to outside of button boundary it should return back to normal immediately.
Do you have any idea for this problem ?

I think you need to target drag event when drags fingers goes out side the boundary of the button it should release the content and here you can check dragoutside event
Triggering a UIButton's method when user drags finger into button's area?

Related

React Native press and hold, drag finger to another touchable and capture touch by that view

In my React Native app I'm trying to have a button that the user can long press, and without lifting their finger, able to interact with another view. Here is roughly what I want:
Think of it like how 3D touch/long press worked prior to iOS 13/14 (depending on place in system and device): user either 3D touched or long pressed a button, for example an app icon, and a contextual menu popped up. Then, users could, without lifting the finger, hover onto one of the buttons and release their finger, triggering the button tap.
I have complete control over my buttons, touchables, and views (even the tab bar is custom, as opposed to the illustrations I made above).
How can I achieve this? (I'm on React Native 0.63)
There may be a better solution to this but off the top of my head I would use the Gesture Responder System
https://reactnative.dev/docs/gesture-responder-system
You can have a one container view that wraps tab bar and buttons. Then listen to the onResponderMove event to decide when these buttons should appear. This may happen for example when the locationY exceeds some value.
You can also use the onResponderRelease event (again with the help of locationX and locationY parameters) to determine if the finger was released above the button.

UIView: Inheriting Touch

Example 1:
When invoking 3D Touch on app icon, you are able to make selections without lifting the finger up.
Example 2
Long pressing on a keyboard key allowing you to drag in to different selections without lifting finger up.
If the app icon is the first view and the pop up is the second view, how can I transfer touch down from first to second view?
Normally, a view loses control of the touches when the fingers leave its area. But if you set isMultipleTouchEnabled to true, it will keep control over touches if the finger leave its area. If you use a button or another UIControl you can assign actions to touchDragExit, touchUpOutside or touchDragOutside etc. to handle events outside of the control.

iOS Scrubbable Buttons

On the keyboard and in the native calculator app on iOS, it's possible to put your finger down on one button, like '0', and then move your finger to the another button, like '1', release your finger, and have it enter '1'. On the calculator it darkens the button under your finger.
If you start pressing a button, drag your finger outside of the buttons, and then move it back in, it'll continue to highlight the buttons under your finger. However, if you don't start on a button—like you start dragging from the calculator results label—and drag onto the buttons, the buttons do not highlight.
What's the best approach to mimic the calculator's behaviour for buttons? I'm mostly looking for code structuring guidance rather than code examples here!
It seems I won't be encapsulate each button in its own view class, but I'll have to have a Keyboard that handles all the touches, and manually draws the buttons.
I think the easiest way is to add handling for touch control events:
UIControlEventTouchDragInside
UIControlEventTouchDragOutside
UIControlEventTouchDragEnter
And link all the components with some kind of processing logic. Initial control event location and so on.

Fire and cancel touch events manually

I have a question about programming my own third-party keyboard for iOS8. My keyboard already looks pretty good, but some functionalities are missing. If you look at the standard keyboard on an iPhone you can press any button and if you swipe your finger to another button, the touch event of the first button gets cancelled and your second button is "active". So e.g. if I press the button "E" and swipe my finger to "R" and release my finger, the letter "R" is the selected one. But I don't know how to implement this.
Now in my app when I press a button and swipe my finger around, this button never gets "released". Seems like I'm stuck on that button as long is I have my finger put on the display.
I think I need these touch events:
TouchUpInside: when the user taps a button, and releases it inside the buttons' frame, this event gets fired (that's when I want to write a letter)
TouchDragInside: That's the event when I already have my finger on the display and swipe my finger "inside" the buttons' frame.
TouchDragOutside: Same as above, just swiping outside the buttons' frame.
But here's the problem: TouchDragInside just get's fired for the button I tap. So when TouchDragOutside gets fired, I have to "release" the button and make the button active where my finger is at the moment.
I hope you understand my question, if you need some further information or some details just let me know.
You could consider not using UIControl at all.
Just use a transparent overlay on top of all the keys so that you can manually deal with which key the message should be dispatched towards.

Smooth transition one gesture to another. How to force start touchesbegan when finger already pressed

I am trying to achieve the following in xcode: One a pan gesture has reached a certain point, I want to draw a draggable item, and have the user's finger automatically keep dragging it around to move the new item. Everything works, except for one problem: The finger needs to be picked up and put down again on the new item when it is initially drawn (I assume to trigger touchesbegan).
Does anyone know if there is a way to force start touchesbegan if the finger is already pressed when the newly drawn item is first rendered (so the user doesn't have to pick up and put down his finger)?

Resources