/** 打开自定义键盘 */ private void openBoard() { if (SKKeyPopupWindow.keyFlagIsShow && !GlobalPopWindow.popIsShow) { popKey.setLastText(showValue); popKey.setShowMax(Integer.toString(info.getnShowCharNumber())); popKey.setShowMin(Integer.toString(0)); popKey.setnStartX(info.getnBoardX()); popKey.setnStartY(info.getnBoardY()); popKey.initPopUpWindow(); // 允许输入 并且勾选了输入提示 则更换背景 if (info.isbIsinput() && info.isbInputSign()) { drawBack = true; SKSceneManage.getInstance().onRefresh(items); } popKey.showPopUpWindow(); } }
/** 系统键盘 */ private void openKey() { // 如果显示类型是密码 则传-1 过去 辨别inputType 是text 还是password if (!GlobalPopWindow.popIsShow && SKKeyPopupWindow.keyFlagIsShow) { if (null != pop) { pop.setCallback(keyback); pop.initPopupWindow(); pop.setInputMax(Integer.toString(info.getnShowCharNumber())); pop.setInputMin(Integer.toString(0)); // 允许输入 并且勾选了输入提示 则更换背景 if (info.isbIsinput() && info.isbInputSign()) { drawBack = true; SKSceneManage.getInstance().onRefresh(items); } pop.showPopupWindow(); } } }
private void doTouch(boolean bitFlag) { if (null == info) { return; } if (!isTouchFlag || !isShowFlag) { return; } if (info.isbIsinput()) { if (info.getnKeyId() == -1) // 为-1 时调用系统键盘 { openKey(); } else { openBoard(); } // 如果是由位地址控制键盘打开的 并且勾选了自动复位 则将那个位地址值复位 if (bitFlag && info.isbAutoChangeBit()) { setBit(info.getsBitAddress(), 0); } } }
@Override public boolean onTouchEvent(MotionEvent event) { // TODO Auto-generated method stub // 允许输入 SKSceneManage.getInstance().time = 0; boolean touch = false; int x = (int) event.getX(); int y = (int) event.getY(); if (null == info) { return false; } if (info.geteInputTypeId() == INPUT_TYPE.BIT) { return false; } if (x < info.getnStartX() || x > info.getnStartX() + info.getnWidth() || y < info.getnStartY() || y > info.getnStartY() + info.getnHeight()) { return false; } else { if (!info.isbIsinput()) { // 不允许输入 直接返回 return false; } else { if (!isTouchFlag || !isShowFlag) { if (!isTouchFlag && info != null) { if (info.getmTouchinInfo() != null) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (info.getmTouchinInfo().isbTouchByUser()) { SKSceneManage.getInstance().turnToLoginPop(); } } } } return false; } if (event.getAction() == MotionEvent.ACTION_DOWN) { isOnclick = true; if (info.getmTouchinInfo() == null) { doTouch(notTouchOpenKey); } else { if (info.getmTouchinInfo().isbTimeoutCancel() == true && info.getmTouchinInfo().getnPressTime() > 0) { if (null == hand) { hand = new myMainHandler(Looper.getMainLooper()); } hand.sendEmptyMessageDelayed( TOUCHHANDER, info.getmTouchinInfo().getnPressTime() * 100); } else { doTouch(notTouchOpenKey); } } touch = true; } else if (event.getAction() == MotionEvent.ACTION_MOVE) { return true; } else if (MotionEvent.ACTION_UP == event.getAction() || MotionEvent.ACTION_CANCEL == event.getAction()) { isOnclick = false; touch = true; } } } return touch; }