Ticket Created

Super Method Call Not Working

When trying to call a parent method it does not get called.

In the below code the GenericDelegate.initialize() method gets called, but the GenericDelegate.onKey(evt) method does not.

This occurs on SDK 4.2.x and 6.2.x, but not on 4.1.x

class RefWatchInputDelegate extends GenericDelegate {

  function initialize() {
    GenericDelegate.initialize();
  }

  // Handle a keyed input
  function onKey(evt as Ui.KeyEvent) as Boolean {
    if (GenericDelegate.onKey(evt)) {
      return true;
    } else if (evt.getKey() == Ui.KEY_DOWN) {
      return dispDevInfoView();
    } else if (evt.getKey() == Ui.KEY_UP) {
      return dispActivityView();
    }

    return false;
  }
}

class GenericDelegate extends Ui.InputDelegate {

  hidden var escPressTime = 0;

  function initialize() {
    Logging.debug("Generic Delegate initialize()");   
    InputDelegate.initialize();
  }

  function onKey(evt as Ui.KeyEvent) as Boolean {
    Logging.debug("Handling Key Event: " + evt.getKey().toString());

    // If the start key is hit
    if (evt.getKey() == Ui.KEY_ENTER) {
      Logging.debug("Enter Key Pressed");
      sendEvtToApp(evt);
      return true;
    }

    // Handle the escape key. Only works on double press
    if (evt.getKey() == Ui.KEY_ESC) {
      var time = Sys.getTimer();

      Logging.debug("ESC Key Pressed at time: " + time.toString());

      if (time - escPressTime <= func.sec2msec(1)) {
        sendEvtToApp(evt);
        escPressTime = 0;
      } else {
        escPressTime = time;
      }
      return true;
    }

    // Handle the menu key press
    if (evt.getKey() == Ui.KEY_MENU) {
      Logging.debug("Menu Key Pressed");
      return dispMainMenu();
    }

    return false;
  }
}

Parents
  • Hi ,

    thanks for taking your time to solve this problem, today I was removing code from my watchface project to send you the zip sample as simple as possible, when I detected that after removing almost all the code and resources it started working, so I copied the full project again and started to remove one thing and test, remove other thing and test, after removing almost all I found out what causes the problem.

    In my case, in the class "Parent extends WatchUi.WatchFace", if you define a static var like this for example:

    class Parent extends WatchFace {
          
        // Configuración de la aplicación
        static var PROPERTY_LOAD_CONFIG_FROM_ID = "LoadConfigurationFrom";
    The "onUpdate" on the parent stops being called, if I remove/comment the static var the "onupdate" on the parent is called. I have other watchfaces where I did not have this problem, so I tested to declare a static var on the parent view class and the problem is reproduced.
    Please, declare the static var on the parent and tell me if you reproduce the problem, if you still can't reproduce it I will send you my sample
    Waiting news from you.
    Thanks
Comment
  • Hi ,

    thanks for taking your time to solve this problem, today I was removing code from my watchface project to send you the zip sample as simple as possible, when I detected that after removing almost all the code and resources it started working, so I copied the full project again and started to remove one thing and test, remove other thing and test, after removing almost all I found out what causes the problem.

    In my case, in the class "Parent extends WatchUi.WatchFace", if you define a static var like this for example:

    class Parent extends WatchFace {
          
        // Configuración de la aplicación
        static var PROPERTY_LOAD_CONFIG_FROM_ID = "LoadConfigurationFrom";
    The "onUpdate" on the parent stops being called, if I remove/comment the static var the "onupdate" on the parent is called. I have other watchfaces where I did not have this problem, so I tested to declare a static var on the parent view class and the problem is reproduced.
    Please, declare the static var on the parent and tell me if you reproduce the problem, if you still can't reproduce it I will send you my sample
    Waiting news from you.
    Thanks
Children
No Data