コード例 #1
0
ファイル: Exactype.java プロジェクト: walles/exactype
  public void onPopupKeyboardTapped(float x, float y) {
    // FIXME: Are we even on the popup keyboard? Abort otherwise.

    float popupX = x - popupX0;
    float popupY = y - popupY0;

    onKeyTapped(popupKeyboardView.getClosestKey(popupX, popupY));
  }
コード例 #2
0
ファイル: Exactype.java プロジェクト: walles/exactype
  public void onRequestPopupKeyboard(char baseKey, float x, float y) {
    String popupKeys = popupKeysForKey.get(baseKey);
    if (popupKeys == null) {
      // No popup keys available for this keypress
      return;
    }

    popupKeyboardView.setKeys(popupKeys);
    popupKeyboardView.setTextSize(view.getTextSize());

    popupKeyboardWindow.setWidth(popupKeyboardView.getMeasuredWidth());
    popupKeyboardWindow.setHeight(popupKeyboardView.getMeasuredHeight());

    // Without this the popup window will be constrained to the inside of the keyboard view
    popupKeyboardWindow.setClippingEnabled(false);

    Timber.d(
        "Popup keyboard window size set to %dx%d",
        popupKeyboardView.getWidth(), popupKeyboardView.getHeight());

    popupX0 = x;
    if (popupX0 + popupKeyboardWindow.getWidth() > view.getWidth()) {
      // Make sure the popup keyboard is left enough to not extend outside of the screen
      popupX0 = view.getWidth() - popupKeyboardWindow.getWidth();
    }
    popupY0 = y;

    // Note that the gravity here decides *where the popup window anchors inside its parent*.
    //
    // This means that if we want the popup window anywhere but to the bottom right of where
    // the user touched, we'll need do the math ourselves.
    popupKeyboardWindow.showAtLocation(view, Gravity.NO_GRAVITY, (int) popupX0, (int) popupY0);
  }