gesture-recognition

UILongPressGestureRecognizer gets called twice when pressing down

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-26 02:39:44
问题 I am detecting if the user has pressed down for 2 seconds: UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; longPress.minimumPressDuration = 2.0; [self addGestureRecognizer:longPress]; [longPress release]; This is how I handle the long press: -(void)handleLongPress:(UILongPressGestureRecognizer*)recognizer{ NSLog(@\"double oo\"); } The text \"double oo\" gets printed twice when I press down for longer than

Draw on HTML5 Canvas using a mouse

痴心易碎 提交于 2019-11-26 00:50:13
问题 I want to draw on an HTML Canvas using a mouse (ex: draw a signature, draw a name,...) Please help me how can I do? Please give some source code. Thank you 回答1: Here is a working sample. <html> <script type="text/javascript"> var canvas, ctx, flag = false, prevX = 0, currX = 0, prevY = 0, currY = 0, dot_flag = false; var x = "black", y = 2; function init() { canvas = document.getElementById('can'); ctx = canvas.getContext("2d"); w = canvas.width; h = canvas.height; canvas.addEventListener(

How to simulate a touch event in Android?

泪湿孤枕 提交于 2019-11-26 00:34:00
How to simulate a touch event with Android while giving the X and Y coordinates manually? azdev Valentin Rocher's method works if you've extended your view, but if you're using an event listener, use this: view.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Toast toast = Toast.makeText( getApplicationContext(), "View touched", Toast.LENGTH_LONG ); toast.show(); return true; } }); // Obtain MotionEvent object long downTime = SystemClock.uptimeMillis(); long eventTime = SystemClock.uptimeMillis() + 100; float x = 0.0f; float y = 0.0f; // List of

Android: How to handle right to left swipe gestures

拈花ヽ惹草 提交于 2019-11-25 21:44:22
问题 I want my app to recognize when a user swipes from right to left on the phone screen. How to do this? 回答1: OnSwipeTouchListener.java : import android.content.Context; import android.view.GestureDetector; import android.view.GestureDetector.SimpleOnGestureListener; import android.view.MotionEvent; import android.view.View; import android.view.View.OnTouchListener; public class OnSwipeTouchListener implements OnTouchListener { private final GestureDetector gestureDetector; public

Fling gesture detection on grid layout

。_饼干妹妹 提交于 2019-11-25 21:39:40
问题 I want to get fling gesture detection working in my Android application. What I have is a GridLayout that contains 9 ImageView s. The source can be found here: Romain Guys\'s Grid Layout. That file I take is from Romain Guy\'s Photostream application and has only been slightly adapted. For the simple click situation I need only set the onClickListener for each ImageView I add to be the main activity which implements View.OnClickListener . It seems infinitely more complicated to implement

Draw on HTML5 Canvas using a mouse

a 夏天 提交于 2019-11-25 20:16:18
I want to draw on an HTML Canvas using a mouse (ex: draw a signature, draw a name,...) Please help me how can I do? Please give some source code. Thank you user1083202 Here is a working sample. <html> <script type="text/javascript"> var canvas, ctx, flag = false, prevX = 0, currX = 0, prevY = 0, currY = 0, dot_flag = false; var x = "black", y = 2; function init() { canvas = document.getElementById('can'); ctx = canvas.getContext("2d"); w = canvas.width; h = canvas.height; canvas.addEventListener("mousemove", function (e) { findxy('move', e) }, false); canvas.addEventListener("mousedown",