BehaviorDelegate onkeypressed issue

Former Member
Former Member
Hi,
I'm trying to port my app designed for touch screen to other devices with button but i'm stuck.

I've been having issues with onkeypressed function from delegate BehaviorDelegate.

I have a condition like
if( keyEvent.getKey().equals( Ui.KEY_DOWN ))

but every time the application exits (no matter i return true or false)
in the console i have just a "Complete"

Any idea ?

thanks!
  • onKeyPressed and onKeyReleased can be a bit problematic on some devices (I never use them)

    Try just using something like
    function onKey(evt)
    var key=evt.getKey();

    if(key==Ui.KEY_DOWN) {
    //your code
    return true;
    }
    return true;
    }


    and for some some things, onBack() onMenu(), etc

    Oh, I wouldn't use equal(). Notice I just use ==
  • Former Member
    Former Member over 7 years ago
    hi jim and thanks for suggestion,


    changed the code as you suggested but no way , same behavior.
    the strange thing is that with KEY_ENTER it works... with other button LIGHT DOWN UP it exits....

    :(

  • Former Member
    Former Member over 7 years ago
    jim tried also with

    function onKey(keyEvent)
    {
    System.println( keyEvent.getKey().toString() );
    return true;
    }

    but it does the same thing....
  • Former Member
    Former Member over 7 years ago
    Is this a widget? Widgets cannot access the up, down or back keys on the initial view because these keys are used to navigate the device UI. If you push additional views via the enter key, those views can use these keys.
  • Like Brian said, widgets are different. Also, what else do you have in the delegate? Which watch? The light button isn't even seen in CIQ.
  • Former Member
    Former Member over 7 years ago
    thanks both.

    yes is a widget. The widget was designeted for va3 but now i'm working to port it to a d2. it's a single view widget..and i should need 2 button.
    Any advice ?


    Marco
  • Former Member
    Former Member over 7 years ago
    The menu key should be available in addition to the enter key in this widget mode. Note that some products provide an intermediate menu to the user prior to passing the menu behavior to this widget mode. I am not sure if D2 has this behavior or not.
  • And for the va3, onMenu() could be used, like on the d2. It's a screen press on the va3.
  • Former Member
    Former Member over 7 years ago
    tried and menu/enter they work.
    nevertheless I've a doubt : if a implement this feature with this 2 button if I press the others , what will happen ? the widget will be killed ?

    Marco
  • Former Member
    Former Member over 7 years ago
    If you press up or down, it will go to the next/previous widget. If you press back, it will return to the clock. Both of these actions will close (kill) the widget.