Back button event

Are any way to change back button in function onKeyReleased( evt ) ?
  • I'm sorry, but it isn't clear what you are trying to do... Could you try describing what you're doing a little more clearly/thoroughly?

    Travis
  • I want redefine action for back button, for long and short press
  • Yes and no, it really depends on what you are trying to do (which you still haven't clearly described).

    If you trying to redefine the behavior of the back button for the built-in watch software or for a watch-app or widget that you do not maintain, Garmin does not provide an application type that offers the ability to intercept key inputs of any type at this level. This might be something that could be done, but it isn't something that is currently available.

    If you are talking about handling key events for an application that you maintain...

    For a widget, you can define the behavior for handling the back button press (BehaviorDelegate.onBack() or InputDelegate.onKey() where the key code is KEY_ESC) for all views except the initial view. The initial view in a widget is special, and the framework is not supposed to pass back key events to it. Have a look at this post for confirmation.

    For a watch-app, you can define the behavior for handling back button press for all views, including the initial view.

    There is an issue on many devices where the onKeyReleased() function isn't called, so you won't be able to implement normal key hold behavior. You can see this post for more information.
  • Thank you it works in onKeyPressed, and how I can prevent back action?
    Are there any other way than cal after this
    Ui.pushView(new MyView(), new MyViewDelegate(), Ui.SLIDE_UP); ?
  • In general, in something like onBack(), returning true indicates you handed the button, and the default behavior should not be performed.
  • corte tornante

    Ок thank you, I understand. And how I can call back action? (not onBack())
  • How I can make standard back action like this?
    function onBack() {
    if (a==1)
    {
    Sys.println("Back Press!");
    }


    if (a==2)
    {
    //// do standart back action
    }

    return true;
    }
  • for a==2 you want to return "false" as that means the standard handling should be done. You return true for both a==1 and a==2
  • If I write like
    function onBack() {

    if (a==1)
    {
    Sys.println("Back Press!");
    return true;
    }
    else
    {
    return false;
    }
    }

    It is work if I click 2 times on back :(