onBack and onSwipe (right) issue with Vivoactive 4

I'm writing my first Garmin software (a watch app) and am I'm struggling to understand if I'm doing something wrong, or if there's an issue with the FW on my watch.

I'm trying to create a view that responds to all four directions of swipe... where the right-swipe does NOT go back, but instead the user uses the (bottom right) back button to do that instead.

Based on comments by Jim in the following discussion, I've implemented the following code...

https://forums.garmin.com/developer/connect-iq/f/discussion/6768/touchscreen-devices---onback-onswipe

var _onBack = false;	
function onBack() {
	System.println("back");
	_onBack = true;
	return false;
}
function onSwipe(evt) {
	var direction = evt.getDirection();
	if (_onBack) {
		System.println(Lang.format("back behavior for swipe $1$", [ direction ]));
	}
	switch(direction) {
		case SWIPE_LEFT: _view.changePrimary(true); break;
		case SWIPE_RIGHT: _view.changePrimary(false); break;
		case SWIPE_UP: _view.changeSecondary(true); break;
		case SWIPE_DOWN: _view.changeSecondary(false); break;
	}
	return true;
}
function onKey(evt) {
	if(_onBack) {
		System.println(Lang.format("back behavior for key $1$", [ evt.getKey() ]));
		WatchUi.popView(WatchUi.SLIDE_RIGHT);
	}
	_onBack = false;
	return true;
}

But I'm seeing major differences between the vivoactive 4 simulator and the watch itself.

On the simulator the right swipe works as expected... with the console showing: back / back behavoir for swipe 3

And the back works as expected.. with the console showing: back / back behavoir for key 5

However, on my physical watch, the right swipe AND the back have identical logs of :back / back behavoir for key 5

There doesn't seem to be a way to override the back functionality of the right-swipe on the physical device.

What am I doing wrong?

  • Use Menu2 (onMenu) to select a player, then up/down to move between holes (onNextPage(),onPreviousPage())?  Select (onSelect()) to increase the score for that hole?

    With this, you'll be compatible with both touch and non touch devices

  • Yes, was thinking along those lines - but the other way around (you'd want the menu to be the hole, and then the up/down to be the player) because you enter all the scores for all players on a single hole before moving onto the next hole.

    It's a big learning curve for an ASP.Net developer ;-)

    Thanks for your help - and sorry for the ranting. I will try and submit a bug report about the simulator soon.

  • You could use a picker (or Menu2) to select a hole, up/down for a player, etc..

    You do what to keep in mind that you'll want a design that will work on non touch devices, or the first request you'll get from a user could be "Can you port this to my forerunner/fenix?"

  • Don't know if you've seen this but there is a disk golf app with source that was done by Garmin:

    https://github.com/garmin/connectiq-apps/tree/master/device-apps/disc-golf

    I've not looked at it myself.

  • No, I hadn't seen that - thanks

  • However, on my physical watch, the right swipe AND the back have identical logs of :back / back behavoir for key 5

    If I understand you correctly, you're saying that the vivoactive4 is making a call to onKey() with a left-to-right swipe, whereas the simulator is making a call to onSwipe(). As you can imagine, this seems like a bug to me.. swiping on a touch screen is not a key press.

    We already have a bug filed for this behavior. It was reported to us in this post:

      forums.garmin.com/.../vivoactive-4s-swipe-identified-as-a-key-pressed

  • Travis - Yes, I concur that this is the same issue... the simulator gives you the ability to tell the difference between a left-to-right swipe via onSwipe, but the physical watch always uses onKey.

    Ideally the watch should act as the simulator (to allow to maximum design flexibility), but if the if the design philosophy of the touch-screen is that the left-to-right should ALWAYS be a back (no matter what) then the simulator should act as the watch.

    Either way, one of them is wrong and should be fixed.

    And should it be the latter, I guess the question then is whether the Graphics.SWIPE_RIGHT should really be deprecated (although obviously removing has knock-on consequences for existing code).

  • Deprecating SWIPE_RIGHT is a non-option. Many devices don't treat a left-to-right swipe as a back gesture. As far as I can recall the only ones that do are the vivoactive family, and even then only the vivoactive4 is treating the swipe as a back key press.

    Unfortunately, fixing this is likely to break at least a few apps. Disappointed