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?

  • Thanks Jim.... I'll give that a go (I have to head out for a while so not sure when that will be.)

    But that doesn't explain the significant difference between the simulator and the physical watch?

  • Sorry Jim, but your answer to the other thread is more about the up/down rather than the right-swipe.

    It mentions that the vivoactive 3 doesn't have a back button, so it always makes a right-swipe an onBack event... but the vivoactive 4 DOES, and if I want to target just the vivoactive 4, why am I unable to override the standard right-swipe functionality?

    In fact, if I wanted to override the standard right-swipe on the 3, why am I not allowed to do that either?

    For the app I want to build, it's near-on-critical to be able to swipe up, down, left AND right without leaving the view.

    I'm getting the feeling that it's simply impossible to do... but it would be nice to have confirmation.

    And the lack of consistency between the simulator and watch is really worrying - if that's so far out, what else is wrong?!  It doesn't give me confidence in the SDK.

  • on the va4, the right swipe is seen as onBack(), and so is the short press of the lower right button.  You can tell the system you handled onBack by returning true instead of false, but you can't tell which action is causing it.

  • In which case it makes it utterly pointless, and therefore I'm unable to make the app I want. Great.

    And as you've now twice ignored the lack of consistency between simulator and watch... well, I'm not sure what to think, other than I have no confidence in this simulator.

  • I'm not Garmin.  Feel free to do a bug report.

    Be sure to include things like the SDK version, and steps to reproduce.  

  • Starting with the va3, and continuing with the va4/venu/varients, devices are more "sensitive" to return values in delegates than the sim.

    In your onKey(), I'm not sure what you are trying to do, as it seems you're trying to do something with any key after onBack(), but one of the keys is KEY_ESC, which is the back button.

  • Don't understand what you mean by "more sensitive"... surely they should be identical, otherwise what's the point?

    I'll figure out how to submit a bug report after I've figure out how I build a UI to get around this annoying functionality.

    Regarding onKey() - I was simply replicating the code you suggested in https://forums.garmin.com/developer/connect-iq/f/discussion/6768/touchscreen-devices---onback-onswipe

    As onBack() is called when pressing the bottom right button, I was simply using it as a way to distinguish between a right-swipe and the button, as per your above suggestion... however, as I now know, it's pointless.

  • I mean on other devices, what you return from callbacks in a delegate didn't matter as much,  You really only had to worry about things like onBack(), but not some like onMenu() and a few others

    There are also things on real device you don't see in the sim, with a common example being handling a long press of a button.  You might code it and it looks good in the sim, but if you run on a device, things go weird.  Long press up on many watches triggers onMenu(), long press down takes you to the music player on some devices.  Long press of the top button on a va4 takes you to controls.  And there are also hotkeys on some devices.

    It's best to stick to the UX Guide.  In your code the callbacks for onBack, onSwipe, and onKey could all see the same event, based on what you don't have commented out (onBack with see events if the other two are comments out.  Comment out onBack and onSwipe, you'll see KEY_ESC in onKey, etc., and onPageNext() and onPagePrevious(), and things get interesting with swipes.

    What is it you are trying to do (big picture, not in code)?

  • I'm trying to create a Garmin version of the UDisc iOS watch app for doing disc golf scoring on the watch. 

    The iOS watch app uses up and down to scroll through the individual players, and left and right to go through each individual hole that you're playing... that's what I'm trying to emulate, but it's obviously not going to be possible.

    So I need to figure out an interface that allows for the user to easily move between rounds, and change the number of shots for each player on the round.

    I've been investigating Menu2 and Picker, but neither seem to do what I need.

    (Note, I've been in touch with UDisc, who do not currently support Garmin, nor do they publish their API in order to communicate with the Android app.  However, I've said I'd like to learn how to code for Garmin watches so that if/when they do release the API it wouldn't be difficult to integrate, and I would dontate the code to them.)