Fenix 3 up-down buttons work on simulator but not on device

Former Member
Former Member
Hey.

I have a view i wish to update every time a user press an "up"/"down" button.
On the simulator it works as expected but in the device every time i press one of the buttons it shows all my view (i have three) but stays on my first view every time.

Here is my code:

function nextPage()
{
Toybox.System.println("nextPage()");
viewNum = (viewNum + 1) % 3;
Ui.requestUpdate();
return true;
}

//! Update the page index for the previous page and request a UI update.
function previousPage()
{
Toybox.System.println("previousPage()");
viewNum--;
if (viewNum < 0) {
viewNum = 2;
}
Ui.requestUpdate();
return true;
}


function onNextPage()
{
Toybox.System.println(" onNextPage() ");
return relatedView.nextPage();
}

function onPreviousPage()
{
Toybox.System.println(" onPreviousPage()");
return relatedView.previousPage();
}


Thank you in advance
  • Former Member
    Former Member over 9 years ago
    Without actually testing your code it looks like it should be fine. What firmware version are you running on your fenix 3? Are there any updates available? I seem to remember seeing a similar issue with older firmware a while ago.

    On a side note, there's a sample disc golf project on GitHub that may be a good reference.
  • Former Member
    Former Member over 9 years ago
    Without actually testing your code it looks like it should be fine. What firmware version are you running on your fenix 3? Are there any updates available? I seem to remember seeing a similar issue with older firmware a while ago.

    On a side note, there's a sample disc golf project on GitHub that may be a good reference.


    Ken I am using the disc golf app as a reference (learned a lot from it) and even there it loops through all the views but then it goes to the next view (it just doesn't look nice) it has something to do with even number of views.
    I will try to update my watch see if it helps
    thank you!
  • Former Member
    Former Member over 9 years ago
    Ken.ConnectIQ my fenix 3 is up to date version 3.80 , do you know what could be the problem? i wish to have 3 views and flip between them but in the device it acts weird and still runs throw all the views.
  • Former Member
    Former Member over 9 years ago
    Is your input delegate extending the Ui.BehaviorDelegate? I took another look at the disc golf code and we are extending a DiscGolfBehaviorDelegate for each of the view's input delegates. The DiscGolfBehaviorDelegate extends Ui.BehaviorDelegate but adds a mapping of the Ui.KEY_ENTER, Ui.KEY_UP and Ui.KEY_DOWN to onEnter(), onPreviousPage() and onNextPage().

    //! Use the basic InputeDelegate to detect the enter key for the fenix 3
    //! and Forerunner 920.
    function onKey(evt) {
    if (evt.getKey() == Ui.KEY_ENTER) {
    return onEnter();
    } else if (evt.getKey() == Ui.KEY_DOWN) {
    return onNextPage();
    } else if (evt.getKey() == Ui.KEY_UP) {
    return onPreviousPage();
    }

    return false;
    }

    // Used to detect the start of the round on a vivoactive
    function onTap(evt) {
    return onEnter();
    }

    //! An enter event has occurred. This is triggered the following ways:
    //! - vivoactive: a tap occurs
    //! - fenix 3: the enter key is pressed
    //! - Forerunner 920: the enter key is pressed
    //! @returns True if the event is handled
    function onEnter() {
    return false;
    }


    The issue I mentioned on older firmware where the up/down keys don't trigger onPreviousPage()/onNextPage() may still exist (I don't have a watch handy to test it) in which case manually mapping them should solve your problem.
  • Former Member
    Former Member over 9 years ago
    Ken I am extending the Ui.BehaviorDelegate, the golf app in my fenix 3 device also doesn't work as expected when you press down or up it runs through all the views in a loop .
    you said mapping them should solve my problem. what do you mean by that? how can i solve this?

    Thank you !:)
  • Former Member
    Former Member over 9 years ago
    you said mapping them should solve my problem. what do you mean by that?


    The code snippet I posted earlier is taken from the DiscGolfBehaviorDelegate which extends Ui.BehaviorDelegate. The Ui.BehaviorDelegate has the function onNextPage() and onPreviousPage(). Inside the DiscGolfBehaviorDelegate I'm overriding onKey() and calling onNextPage() when the Ui.KEY_DOWN key is pressed and onPreviousPage() when the Ui.KEY_UP key is pressed. This solved one issue with the fenix 3 (I don't know if the underlying issue has been fixed or not) where the up and down keys were not properly mapped to onPreviousPage() and onNextPage() at the firmware level.

    I am extending the Ui.BehaviorDelegate, the golf app in my fenix 3 device also doesn't work as expected when you press down or up it runs through all the views in a loop .


    I'm not sure I completely understand the issue you are seeing. A single key press is cycling through all the views in your loop at which point you end up back on the original view? You could send your app and steps to reproduce your problem to [email][email protected][/email] and one of us will try to take a look at it and get back to you.
  • I believe this may be related to what was discussed over on this thread:

    https://forums.garmin.com/showthread.php?312324-Fenix-3-input-event-handling

    If so, we already have a fix in that should be available in the next release. The temporary way to handle this is to intercept the individual keys rather than behaviors.