I have been trying to make similar behavior to a traditional View's ACTION_MOVE touch event in Compose. Basically I have a grid of 4x4 Box items, and I want to have a way to touch/click down outside of them, and then drag into them, and have the drag event fire.
I have tried with pointerInput(Unit) { detectDragGestures { but this is only working for me if I click down inside the box and then drag, not if I start dragging outside the box and then drag into it like I can with a TouchListener.
Is there another method to use?
Related
I have a THorzScrollBox with 3 TLayout controls inside it.
I put some code to make HorzScrollBox1.AniCalculations.SetTargets go to the layout I want based on my scroll and it was a success running.
But when I put TListView inside the TLayout, I can't scroll it, because the HitTest of the TListView is enabled. I must disable it to scroll the THorzScrollBox, but if I do then the TListView can't scroll vertically.
If you look the alFmxControl.apk demo of alcinoe (https://github.com/Zeus64/alcinoe) you will see that it's handle something similar, but instead of TlistView it's a Tabcontrol and vertScrollBox.
To resume the idea both TabControl and the VertScrollBox receive the mousemove event and as soon as you move you finger more on the left or right then the vertscrollbox is deactivated and only the tabcontrol receive futur mouse event, or as soon as you move your finger more on the up or down then it's the opposite, tabcontrol is deactivated and only the scrollbox receive the mouse event.
Mouse event are handled via CMGesture that as i remember don't care if a child controls catch the mouse event via it's hittest property
You can inspire from this code to see how to transpose it to your TListView
I've got a custom View which wills the screen. I've built its onDraw code to support a pinch-zoom style of zooming in and out. The View itself handles all of this work.
Additionally though, I'd like to allow the user to swipe across the screen, either left or right, so that I can swap out that view with the view before or after (similar to a paging situation).
I was able to capture and respond to the swipe left and right using a GestureOverlayView, but now that overlay view is intercepting my pinch-zooming touch events. How can I allow those pinch-zooming touch events to fall through to the custom View will grabbing the swiping gestures up at the activity level?
I think you might want to use a ViewFlipper with a GestureDetector instead of a GestureOverlayView.
http://android-er.blogspot.com/2012/02/implement-swiping-page-effect-using.html
with a setup like this, the gesture detector should only accept left/right swipes, while the view currently displayed still controls the pinch-zoom effect
Hi all in my android app I move objects on screen as per user input.
Basically I have to take care of two inputs - drag and UP(touch & remove)
So I implemented Gesture listener where the two methods -
onScroll() & onSingleTapUp() were used to handle these two input events.
But onSingleTapUp() does not work if the user has kept her finger for a long time on screen and then lifted it up.
So the conditions now require me implement onTouch to harness the MotionEvent.ACTION_UP functionality.
But would it be a good idea to use both onTouch & Gesture Listener.
Or should I shift my code to onTouch and remove gesture listener ?
I have two scrollviews side by side, I want the user to be able to drag list items back and forth from left to right scrollviews. However, I can't find a way to handle the touch events. I can't set a touch listener for each scrollview seperately as the drag gesture gets dropped when passing from one to another. I tried creating an absolute layout over the top of both, which works from the drag and drop perspective, but it stops me from being able to scroll the scrollviews. Is there a simple solution to this? can anyone help me out?
Generally, onTouchListener returns a boolean that indicates whether the touch has been handled. It's up to you to decide whether the touch was handled or not. When the user touches a View, Android will call it's touch listener. If the touch listener returns true, then it regards the touch as handled then moves on. If the touch listener returns false, then it will go up one to the parent view (in this case whatever your ScrollView is). Then the parent view's touch listener is called and must decide how to handle the touch. It will keep cascading up the parent views until a true is returned or until it reaches the end.
In your case, you may have to decide what the user has to do in order to drag & drop vs. scrolling. Perhaps the user must do a long press on an item before he/she can drag it or something.
Sorry for the complex question let me explain.
I've created a custom widget that handles some ontouch events. What i want to do is when i start a touch event on that custom widget (onDown) i want that widget to keep handling these event even if the absolute coordinations are not in that widget.
I have a scrollview and on top of that(inside the scrollview) a widget that handles (left - right) scrolls. But if i move the finger vertically the ontouch events are consumed and handled by the scollview. If there a way to forbit scrollview to handle touch events , or better force the custom widget to keep handling the touchEvent, if i start the ontouchEvent inside the custom widget?
UPDATE I came across that http://groups.google.com/group/android-framework/browse_thread/thread/2cdd4269dfb2772e?pli=1 .
That works in my case if the custom widget is NOT inside a scrolling view like "ScrollView". Trying to solve the "Beeing inside a scrolling object. How to not send these on touchevents to the parent? Returning true doesn't solve the problem
In your widget's onTouch handler (e.g. during ACTION_MOVE), call the parent.requestDisallowInterceptTouchEvent(true). That method basically is asking the parent (in your case the scrollview) and its ancestor not to intercept the touch event.
You will need to implement a special subclass of ScrollView, which allows your widget to tell it to disable scrolling when desired (so it won't start scrolling after enough movement and take events from your widget). The custom ScrollView can override this method:
http://developer.android.com/reference/android/widget/ScrollView.html#onInterceptTouchEvent(android.view.MotionEvent)
When you don't want the base class to consume touch events for scrolls, return false here instead of calling the base implementation.