Newbie question .. how to disable Back button on Vivoactive HR

Former Member
Former Member
I would like to disable the back button in my application on the Vivoactive HR and searched and cannot find the answer.

I just want the backlight to come on when pressing the back button which seems to work in the simulator.

I am hoping this thread will help some newbie like me in the future as well. :cool:

This is my code thus far .. and looks like that would go in the KEY_DOWN_LEFT.

function onKey(evt)
{
if(evt.getKey()==Ui.KEY_ENTER || evt.getKey()==Ui.KEY_START) // START - RIGHT KEY
{
if (( session != null ) && session.isRecording() )
{
session.stop();
Att.backlight(true);
Ui.pushView(new Rez.Menus.MainMenu(), new PodMenuDelegate(), Ui.SLIDE_UP);

}
else
{
Att.backlight(true);
Ui.pushView(new Rez.Menus.WorkMenu(), new PodMenuDelegate(), Ui.SLIDE_UP);

}

}

if (evt.getKey() == Ui.KEY_DOWN_LEFT) // BACK - LEFT KEY
{
Att.vibrate(vibrateDataShort);
Att.backlight(true);
}
}
  • Return "true" for buttons that you don't want the native handler to deal with, false if you do want the default action.
  • Former Member
    Former Member over 8 years ago
    Return "true" for buttons that you don't want the native handler to deal with, false if you do want the default action.


    Thank you .. :cool:

    EDIT .. well the back does not work now. But neither does the backlight or vibrate. I would like those to work as strange as that is. ;-)

    if (evt.getKey() == Ui.KEY_DOWN_LEFT) // BACK - LEFT KEY
    {
    Att.vibrate(vibrateDataShort);
    Att.backlight(true);
    }
    return (true);
  • Former Member
    Former Member over 8 years ago
    You only want to return true for the back key, not all keys:

    var ret = false;
    if (evt.getKey() == Ui.KEY_DOWN_LEFT) // BACK - LEFT KEY
    {
    Att.vibrate(vibrateDataShort);
    Att.backlight(true);
    ret = true;
    }

    return ret;
  • Former Member
    Former Member over 8 years ago
    You only want to return true for the back key, not all keys:

    var ret = false;
    if (evt.getKey() == Ui.KEY_DOWN_LEFT) // BACK - LEFT KEY
    {
    Att.vibrate(vibrateDataShort);
    Att.backlight(true);
    ret = true;
    }

    return ret;



    Thanks .. I thought it was something like that, just did not know how to do it.

    EDIT .. at least in the simulator that does not prevent the back button from working. I am thinking my Key Code is wrong. I will investigate that.
  • I always use onBack() for the back key. Try commenting out every thing for left_button_down, and have onBack() at the same level as onKey()
  • Former Member
    Former Member over 8 years ago
    I was able to go and do ..

    var type = getKey();
    System.println(type);

    That gave me 5 .. which works but I would like to know what constant that is.

    EDIT .. used onBack .. it works perfectly. Thanks jim_m_58
  • Former Member
    Former Member over 8 years ago
    The constants are listed in the docs. If you look at the WatchUi module you will see the 5 = KEY_ESC
  • Former Member
    Former Member over 8 years ago
    The constants are listed in the docs. If you look at the WatchUi module you will see the 5 = KEY_ESC


    Thank you .. I will look.