FlickEvent -- what is a flick?

I wonder, what a flick is? I did a google search (please mind, that I am no native English speaker) and found the term being used in conjunction with 'wrist', like wrist flick.

In the docs (https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi/FlickEvent.html) you read:

FlickEvent is an object sent to InputDelegate when there is a flick interaction with the device's touch screen.

The event has some interesting properties, like:

I searched through the docs, and found no info. There is no example for FlickEvent, either.

Can someone explain, what is the flick event and when it occurs?

Is there a way to reproduce a flick in the simulator?

Regards,

Karol

  • I think this is like a swipe, but for a shorter period of time / shorter distance (and in an arbitrary direction, not just up, down, left or right.) Same as how a wrist flick is a quick movement of your wrist.

    You should be able to reproduce in the simulator with the mouse/trackpad. Point at watch screen in simulator, hold (left) button, move mouse quickly, release button.

  • It's a System 5 thing (Since API Level 3.3.0).  In addition to onFlick, there's also onDrag.  You get onDrag as you drag your finger across the screen and onFlick when you pull your finger off the screen

    Here's some code I have in the delegate for a test app.  It just counts flicks and drags so you can see when things happen.

    	function onFlick(evt) {
    		//System.println("flick="+evt.getDirection());
    		view.flick++;
    		WatchUi.requestUpdate();
            return true;
    	}
    	
        function onDrag(evt) {
            //System.println("drag="+evt.getCoordinates()); // e.g. [36, 40]
            view.drag++;
            WatchUi.requestUpdate();
            return true;
        }

  • I have a question about this, and getting access to the touchscreen in general. I'm quite new to developing and can't seem to get this to work.

    I put this piece of code inside and extension for WatchUi.InputDelegate and it seems to compile alright. However, once I get the CIQ Simulator - Forerunner 955 / Solar and start clicking or dragging on the screen, nothing happens.

    Is there anything else I need to do in the simulator? Or turn on some sort of setting?

    ----------

    class MyInputDelegate extends WatchUi.InputDelegate {


        function initialize() {
            InputDelegate.initialize();
        }

        function onFlick(evt) {
            System.println("flick="+evt.getDirection());
            //view.flick++;
            WatchUi.requestUpdate();
            return true;
        }
       
        function onDrag(evt) {
            System.println("drag="+evt.getCoordinates()); // e.g. [36, 40]
            //view.drag++;
            WatchUi.requestUpdate();
            return true;
        }
    }
  • What type of app?  No input to a watch face for example.

    Are you specifying the delegate in the return to getInitialView?

  • I'm trying to build an app indeed. No watch face or data field.

    My current getInitialView looks like this

        function getInitialView() as Array<Views or InputDelegates>? {

            _view = new UltimateTennisView();
            _match = new scoring();
            return [ _view, new UltimateTennisDelegate() ] as Array<Views or InputDelegates>;
        }
  • Which  SDK ans are your devices up to date?

    Try adding onSwipe to your delegate to check a normal swipe..

    Also, in the sim, under settings, make sure "Toggle Touch Screen" is checked.

  • I just downloaded the SDK 2 weeks ago and I believe everything is up to date. The touch screen toggle is on and I just found out the functionality of clicking and swiping work as part of the BehaviorDelegate onSelect and onBack. Below the entire BehaviorDelegate and InputDelegate. Maybe you can spot anything curious?

    (A 2nd issue I have is that I cannot print get the getKey to print but I don't want to start 2 different discussions on this thread)

    ---------

    import Toybox.Lang;
    import Toybox.WatchUi;

    class UltimateTennisDelegate extends WatchUi.BehaviorDelegate {

        private var _view = getView();

        function initialize() {
            BehaviorDelegate.initialize();
        }

        function onSelect() {
            System.println("Select");        
            return true;
        }

        function onBack() {
            System.println("Back");      
            return true;
        }

        function onMenu() as Boolean {
            WatchUi.pushView(new Rez.Menus.MainMenu(), new UltimateTennisMenuDelegate(), WatchUi.SLIDE_UP);
            return true;
        }

        function onKey(evt as KeyEvent) as Boolean {
           
            //System.println(evt.getKey());

            // ignoring other KeyEvents
            return true;
        }

    }

    class MyInputDelegate extends WatchUi.InputDelegate {

        function initialize() {
            InputDelegate.initialize();
        }

        function onFlick(evt) {
            System.println("flick="+evt.getDirection());
            //view.flick++;
            WatchUi.requestUpdate();
            return true;
        }
       
        function onDrag(evt) {
            System.println("drag="+evt.getCoordinates()); // e.g. [36, 40]
            //view.drag++;
            WatchUi.requestUpdate();
            return true;
        }
    }


  • You don't want both a Behavior and Input delegate.  I just use Behavior, and that's what I return in getInitialView().

    Also, onKey() is for buttons and doesn't catch things like swipes.

    With onNextPage(), onPreviousPage, you can catch both up/down buttons and up/down swipes..  onMenu() for the menu key, onSelect for screen taps and the upper right button, and onBack() for Key_ESC.

  • Ow wow... that solved it :). I removed the BehaviorDelegate all togher.

    I am trying to get an interaction in which different parts of the screen represent different types of scores (like top part = player 1 scores and bottom part = player 2 scores). So I figured I need the inputdelegate. But just to confirm, I cannot combine the Behavior and Input Delegate? I will now have to specify what the physical buttons do?

    I have copied the onKey into my - now working - inputdelegate but it still throws the same error...

    -------

        function onKey(evt as KeyEvent) as Boolean {
           
            //System.println(evt.getKey());

            // ignoring other KeyEvents
            return true;
        }