Detect shake gesture IOS Swift

Swift3 ios10: override func viewDidLoad() { super.viewDidLoad() self.becomeFirstResponder() // To get shake gesture } // We are willing to become first responder to get shake motion override var canBecomeFirstResponder: Bool { get { return true } } // Enable detection of shake motion override func motionEnded(_ motion: UIEvent.EventSubtype, with event: UIEvent?) { if motion == … Read more

How can a service listen for touch gestures/events?

I had this same problem and I’ve finally figured it out! Thanks to this post: Creating a system overlay window (always on top). You need to use an alert window instead of an overlay (and this also means you can use it in Andoid ICS): WindowManager.LayoutParams params = new WindowManager.LayoutParams( WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE|WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL|WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); Then just … Read more

Gesture detection in Flutter TextSpan

You can improve by yourself import ‘package:flutter/gestures.dart’; … new RichText( text: new TextSpan(text: ‘Non touchable. ‘, children: [ new TextSpan( text: ‘Tap here.’, recognizer: new TapGestureRecognizer()..onTap = () => print(‘Tap Here onTap’), ) ]), );

SwipeRefreshLayout + ViewPager, limit horizontal scroll only?

I am not sure if you still have this issue but Google I/O app iosched solves this problem thusly: viewPager.addOnPageChangeListener( new ViewPager.OnPageChangeListener() { @Override public void onPageScrolled( int position, float v, int i1 ) { } @Override public void onPageSelected( int position ) { } @Override public void onPageScrollStateChanged( int state ) { enableDisableSwipeRefresh( state … Read more

Draw on HTML5 Canvas using a mouse

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) { … Read more