Acknowledged

keyEvent.getKey() == 4 short vrs long pressed

Hi! I have the following problem, you might know the reason/solution.

I have the following code line:  if (keyEvent.getKey() == 4) {onSelect_lauch();}

I found that, in the simulator, for several devices, when I press the "Start-Stop buttom" (Key 4), if I press it long (not just one click but a "long" click), it launches properly the function but if I press it short, I gives me the typical error "Symbol Not found Error". It is an App (not a widget).

Error: Symbol Not Found Error

Details: Failed invoking <symbol>

Stack:

Do you know why and how to solve it?

Thanks!

Parents
  • I found that, in the simulator, for several devices, when I press the "Start-Stop buttom" (Key 4), if I press it long (not just one click but a "long" click), it launches properly the function but if I press it short, I gives me the typical error "Symbol Not found Error". It is an App (not a widget).

    ...

    public function onSelect_Battle() as Boolean {
            WatchUi.pushView(new $.Steps_Battle_AttackView(), new $.EntryMenuDelegate(), WatchUi.SLIDE_BLINK);
            return true;
        }

    When pushed fast the KEY_ENTER, gives the error, if pushed "slow" it works. Similar response if: if (keyEvent.getKey() == 4) {onSelect_Battle();}

    If I change to function to the following one, it works for short and long pressed.

    public function onSelect_Battle() as Boolean {
            System.println("Activated")
            return true;
        }
    I think the problem here is with the use of WatchUi.SLIDE_BLINK. According to the docs (https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html) WatchUi.SLIDE_BLINK is only available for devices with CIQ 3.1.0 and higher.
    If you need to support other devices, you'll have to use this conditionally. e.g.
    WatchUi.pushView(
      new $.Steps_Battle_AttackView(),
      new $.EntryMenuDelegate(),
      WatchUi has :SLIDE_BLINK ? WatchUi.SLIDE_BLINK : WatchUi.SLIDE_IMMEDIATE
    );
Comment
  • I found that, in the simulator, for several devices, when I press the "Start-Stop buttom" (Key 4), if I press it long (not just one click but a "long" click), it launches properly the function but if I press it short, I gives me the typical error "Symbol Not found Error". It is an App (not a widget).

    ...

    public function onSelect_Battle() as Boolean {
            WatchUi.pushView(new $.Steps_Battle_AttackView(), new $.EntryMenuDelegate(), WatchUi.SLIDE_BLINK);
            return true;
        }

    When pushed fast the KEY_ENTER, gives the error, if pushed "slow" it works. Similar response if: if (keyEvent.getKey() == 4) {onSelect_Battle();}

    If I change to function to the following one, it works for short and long pressed.

    public function onSelect_Battle() as Boolean {
            System.println("Activated")
            return true;
        }
    I think the problem here is with the use of WatchUi.SLIDE_BLINK. According to the docs (https://developer.garmin.com/connect-iq/api-docs/Toybox/WatchUi.html) WatchUi.SLIDE_BLINK is only available for devices with CIQ 3.1.0 and higher.
    If you need to support other devices, you'll have to use this conditionally. e.g.
    WatchUi.pushView(
      new $.Steps_Battle_AttackView(),
      new $.EntryMenuDelegate(),
      WatchUi has :SLIDE_BLINK ? WatchUi.SLIDE_BLINK : WatchUi.SLIDE_IMMEDIATE
    );
Children
  • Thanks your your reply. However, this does not seem to be the problem. I tried with your code and still not working...the problem is the duration the buttom button 4 is pressed. If pressed just once, quick, does not work, if pressed once long (push, wait, release) it works...