touch-event

How to send touch events to nextResponder in Swift

匆匆过客 提交于 2019-12-05 23:34:05
Background I'm trying to make a UICollectionViewCell behave like a button (ie, do an animated dim on touch). I had the idea of just filling the cell with a UIButton . The button would then take care of the visual effect of being tapped. But then I would need to pass the touch event on to the parent (the UICollectionViewCell ) so that the button does not just consume the event. That way I could handle it with the collection view's didSelectItemAtPath . The problem below is my attempt to figure out how to pass the event on. My problem I came across this Objective-C answer for passing the touch

Pass touch event from NestedScrollView to parent view's

吃可爱长大的小学妹 提交于 2019-12-05 21:14:48
I have a ViewPager below a NestedScrollView width some top padding, and clipToPadding(false) and transparent background (like as image). My ViewPager can't get touch event and doesn't work. How can I solve this problem? (I can't change my structure and can't move ViewPager to above of NestedScrollView or set TopMargin to NestedScrollView) NestedScrollView nestedScrollView = new NestedScrollView(getContext()); nestedScrollView.setFillViewport(true); nestedScrollView.setLayoutParams(scrollParams); nestedScrollView.setClipToPadding(false); Solution: This Problem solved With overwriting

android (singletouch) drawing app undo method not working properly

只愿长相守 提交于 2019-12-05 17:56:21
I am working on a drawing app but facing some undo problems. The coding is as follows: public class DoodleView extends View { Context context_new; private static final float TOUCH_TOLERANCE = 5; private Bitmap bitmap; // drawing area for display or saving private Canvas bitmapCanvas; // used to draw on bitmap private Paint paintScreen; // use to draw bitmap onto screen private Paint paintLine; // used to draw lines onto bitmap private Path mPath; private ArrayList<Path> paths = new ArrayList<Path>(); private ArrayList<Path> undonePaths = new ArrayList<Path>(); private float mX, mY; //

How do I get the coordinates of a map on tap with MapFragment (not MapView)?

霸气de小男生 提交于 2019-12-05 17:01:35
问题 I have searched around on how to get the coordinates of a location when the map is tapped. However, most, if not all the examples require a MapView as a parameter. For example: public boolean onTap(GeoPoint p, MapView map){ if ( isPinch ){ return false; }else{ Log.i(TAG,"TAP!"); if ( p!=null ){ handleGeoPoint(p); return true; // We handled the tap }else{ return false; // Null GeoPoint } } } @Override public boolean onTouchEvent(MotionEvent e, MapView mapView) { int fingers = e.getPointerCount

Android GestureDetector with SimpleOnGestureListener within SurfaceView

余生长醉 提交于 2019-12-05 12:08:57
public class GameActivity extends Activity { private static final String TAG = "GameActivity"; . . . @Override public boolean onTouchEvent(MotionEvent event) { Log.d(TAG, "+ onTouchEvent(event:" + event + ")"); Log.d(TAG, "- onTouchEvent()"); return super.onTouchEvent(event); } . . . } public class GameView extends SurfaceView implements SurfaceHolder.Callback { private static final String TAG = "GameView"; . . . @Override public boolean onTouchEvent(MotionEvent event) { Log.d(TAG, "+ onTouchEvent(event:" + event + ")"); gestureDetector.onTouchEvent(event); Log.d(TAG, "- onTouchEvent()");

View.onTouchEvent only registers ACTION_DOWN event

落爺英雄遲暮 提交于 2019-12-05 12:05:38
问题 I'm implementing a custom TextView and I want to do some action when the view is touched. I figured the onTouchEvent method would give me the full range of touches on the view without having to use setOnTouchListener (I'm trying to do all my work inside the view instead of in the activity so it's portable), but the only touch event registered is ACTION_DOWN . If I set an OnTouchListener in the activity using this, I get the full range of touch events, but onTouchEvent doesn't. Anyone know why

How to Highlight this pdf page using Ontouchevent in android

允我心安 提交于 2019-12-05 06:08:34
Here I want to highlight this text using onTouchevent in android You could use OnTouchListener to get the x and y of the event. Then drawing the screen to a bitmap and using bitmap.getPixel based on the top left display of the letter nd the size of your letters, to see if the next letter(s) next to it are also not spaces.Finally, put a yellow rectangle in between the white and the black lettering or the ones you wish to have highlighted. Shreyash Mahajan You have to implement the onTouchListener for the button or any view you want. as like below: implement the OnTouchListener: public class

How to capture onTouch events on two overlapping views?

偶尔善良 提交于 2019-12-05 05:20:07
Layout ! * Container is a relative layout contains two custom views: OuterView1 and InnerView2 * Outer View1 is a custom view, matching the parent’s size (full screen) * Inner View2 is also a custom view, laid on top of OuterView1 overlapping it. Container is a relative layout contains two custom views: OuterView1 and InnerView2 Outer View1 is a custom view, matching the parent’s size (full screen) Inner View2 is also a custom view, laid on top of OuterView1 overlapping it. On both OuterView1 and InnerView2, I want to capture these touch events onSingleTapConfirmed() and onFling(). The area

In SpriteKit does touchesBegan run in the same thread as the SKScene update method?

时光怂恿深爱的人放手 提交于 2019-12-05 04:18:23
In the Apple documentation here Advanced Scene Processing it describes the update method and how a scene is rendered, but it does not mention when input is processed. It is not clear if this is in in the same thread as the rendering loop, or whether it is concurrent with it. If I have an object that I update from both the SKScene update method and the touchesBegan method (in this case of a SKSpriteNode ) do I have to worry about synchronising the two accesses to my object? So after a few days with no answer I set up some experiments. By the way, these tests are run on the simulator and not on

Adding TapGestureRecognizer to UILabel in Swift

冷暖自知 提交于 2019-12-05 03:58:00
I add a UITapGestureRecognizer:tapGesture , I want that when I click(touch) the label, klikPlay() will run its actions. when I run the code and click/touch the label, it gives this error: unrecognized selector sent to instance. It is about the label Player(named: label) , the UITapGestureRecognizer(named:tapGesture) and the function klikPlay What am I doing wrong? override func didMoveToView(view: SKView) { let background = SKSpriteNode(imageNamed: "bgStart2") background.position = CGPoint(x:0, y:0) background.anchorPoint=CGPoint(x:0,y:1.0) background.size = frame.size addChild(background) /