Пример #1
0
  protected boolean keyDown(int in_nKeyCode, int in_nTime) {
    int nKeyPressed = Keypad.key(in_nKeyCode);

    if (nKeyPressed == Keypad.KEY_MENU) {
      if (gbrfield.getText() != null || gbrfield.getGbr() != null) {
        askWhat();
        return true;
      }
    }

    return super.keyDown(in_nKeyCode, in_nTime);
  }
Пример #2
0
  protected boolean keyDown(final int keycode, int time) {
    System.out.println("***** keyDown *****");
    System.out.println("keycode=" + keycode);
    char altedKey = '0';
    boolean useAltedKey = false;
    final int key;
    boolean isAltedKeyboard = false;
    try {
      isAltedKeyboard = hwKeyboardLayoutsLst.containsKey(Keypad.getHardwareLayout());
      // System.out.println("hw layout " + Integer.toString(Keypad.getHardwareLayout()) +
      // (isAltedKeyboard ? " alted" : " non-alted") );
    } catch (Exception e) {
      System.out.println("contains Exception " + e);
    }
    if (isAltedKeyboard) { // Alted keyboard
      altedKey = Keypad.map(Keypad.key(keycode), KeypadListener.STATUS_ALT);
      if ((altedKey == '#') || (altedKey == '*')) { // enable zoom in zoom out.
        useAltedKey = true;
      }
    }

    if (keyDownStackAddress == 0) {
      Logger.log("keyDownStackAddress = 0, before stack init ");
      return true;
    }

    key = Keypad.key(keycode);

    System.out.println("key is = " + key);

    final int status = Keypad.status(keycode);
    // System.out.println("key=" + keycode + " status=" + status);

    if (key == Keypad.KEY_MENU) {
      System.out.println("***** MENU BUTTON PRESSED *****");
      menu_open = true;
      try {
        if (c_on_menu_key_down == 0) {
          c_on_menu_key_down = CibylCallTable.getAddressByName("rim_on_menu_button");
        }
        if (c_on_menu_key_down != 0) {
          // FIXME - should send keycode to C and C should trans to UTF8
          updateUTF8Key(keycode);
          CibylCallTable.call(c_on_menu_key_down, keyDownStackAddress, key, status, time, 0);
        }
      } catch (Exception t) {
        Logger.log("Exception in UI action: " + t);
        t.printStackTrace();
      }
      return false; // return false so RIM will open the menu as necessary.
    } else if (key == Keypad.KEY_VOLUME_DOWN) {
      SoundMgr.updateSoundLevel(-10);
    } else if (key == Keypad.KEY_VOLUME_UP) {
      SoundMgr.updateSoundLevel(10);
    } else if ((key == Keypad.KEY_SEND)
        || (key == Keypad.KEY_APPLICATION)
        || (key == Keypad.KEY_SPEAKERPHONE)
        || (key == Keypad.KEY_CONVENIENCE_1)
        || (key == Keypad.KEY_CONVENIENCE_2)) {
      return false;

    } else if (key == Keypad.KEY_END) {
      return false;
    } else {
      try {
        if (c_on_key_down == 0) c_on_key_down = CibylCallTable.getAddressByName("rim_on_key_down");
      } catch (Throwable t) {
        Logger.log("Exception in keyDown: " + t);
        t.printStackTrace();

        System.exit(0);
      }

      if (c_on_key_down != 0) {
        // FIXME - should send keycode to C and C should trans to UTF8
        if (!useAltedKey) updateUTF8Key(keycode);
        else updateUTF8Key(altedKey);

        UIWorker.addUIEvent(c_on_key_down, key, status, time, 0, true);
      }
    }
    return true;
  }
Пример #3
0
 public static void updateUTF8Key(int keycode) {
   char c = Keypad.map(keycode);
   updateUTF8Key(c);
 }
 /**
  * Handles key events.
  *
  * <p>WARNING: When this method should be overwritten, one need to ensure that super.keyPressed(
  * int ) is called!
  *
  * @param keyCode The code of the pressed key
  * @see de.enough.polish.ui.Screen#keyPressed(int)
  */
 public void keyPressed(int keyCode) {
   if (Keypad.key(keyCode) == Keypad.KEY_ESCAPE) commandAction(cmdBack, this);
   else super.keyPressed(keyCode);
 }
Пример #5
0
 /**
  * Handles key events.
  *
  * <p>WARNING: When this method should be overwritten, one need to ensure that super.keyPressed(
  * int ) is called!
  *
  * @param keyCode The code of the pressed key
  */
 public void keyPressed(int keyCode) {
   if (Keypad.key(keyCode) == Keypad.KEY_ESCAPE) getCommandListener().commandAction(cmdQuit, this);
   else super.keyPressed(keyCode);
 }