本文整理汇总了Java中javax.microedition.lcdui.Canvas.KEY_NUM1属性的典型用法代码示例。如果您正苦于以下问题:Java Canvas.KEY_NUM1属性的具体用法?Java Canvas.KEY_NUM1怎么用?Java Canvas.KEY_NUM1使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.microedition.lcdui.Canvas
的用法示例。
在下文中一共展示了Canvas.KEY_NUM1属性的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: InputManager
private InputManager() {
up = new Input(Canvas.UP);
down = new Input(Canvas.DOWN);
left = new Input(Canvas.LEFT);
right = new Input(Canvas.RIGHT);
fire = new Input(Canvas.FIRE);
gamea = new Input(Canvas.GAME_A);
gameb = new Input(Canvas.GAME_B);
gamec = new Input(Canvas.GAME_C);
gamed = new Input(Canvas.GAME_D);
num0 = new Input(Canvas.KEY_NUM0);
num1 = new Input(Canvas.KEY_NUM1);
num2 = new Input(Canvas.KEY_NUM2);
num3 = new Input(Canvas.KEY_NUM3);
num4 = new Input(Canvas.KEY_NUM4);
num5 = new Input(Canvas.KEY_NUM5);
num6 = new Input(Canvas.KEY_NUM6);
num7 = new Input(Canvas.KEY_NUM7);
num8 = new Input(Canvas.KEY_NUM8);
num9 = new Input(Canvas.KEY_NUM9);
star = new Input(Canvas.KEY_STAR);
pound = new Input(Canvas.KEY_POUND);
}
示例2: isNumKey
private boolean isNumKey(int keyCode) {
return keyCode >= Canvas.KEY_NUM1 && keyCode <= Canvas.KEY_NUM9;
}
示例3: handleKeyPressed
protected boolean handleKeyPressed(int keyCode, int gameAction){
//We might want to handle number keys if we aren't focussed, but we don't want to handle anything else
if(!this.isFocused && !isNumKey(keyCode)) {
return false;
}
//In numeric navigation mode, so we only want to allow navigation with those keys, and
//hide other cues
if(numericNavigation) {
//Reject up and down
if((gameAction == Canvas.UP || gameAction == Canvas.DOWN) && !isNumKey(keyCode)) {
return false;
}
//If the user hasn't made a navigation choice, swallow the fire key.
if(!touched && getScreen().isGameActionFire(keyCode, gameAction)) {
return false;
}
}
//
if(isNumKey(keyCode)) {
touch();
if(!autoSelect) {
int index = keyCode-Canvas.KEY_NUM1;
if(index < this.itemsList.size()){
doAudio(index,true);
if(this.parent != null && this.parent instanceof Container) {
Container c = (Container)this.parent;
c.focusChild(c.indexOf(this));
}
super.focusChild(index);
}else{
return super.handleKeyPressed(keyCode,gameAction);
}
return true;
} else {
return super.handleKeyPressed(keyCode,gameAction);
}
}
return super.handleKeyPressed(keyCode,gameAction);
}
示例4: parseKeyboardKey
private int parseKeyboardKey(String keyName)
{
if (keyName == null) {
return -1;
}
// TODO poprawic KeyEvent
if (keyName.equals("VK_LEFT")) {
return SWT.ARROW_LEFT;
} else if (keyName.equals("VK_RIGHT")) {
return SWT.ARROW_RIGHT;
} else if (keyName.equals("VK_UP")) {
return SWT.ARROW_UP;
} else if (keyName.equals("VK_DOWN")) {
return SWT.ARROW_DOWN;
} else if (keyName.equals("VK_ENTER")) {
return SWT.CR;
} else if (keyName.equals("VK_F1")) {
return SWT.F1;
} else if (keyName.equals("VK_F2")) {
return SWT.F2;
} else if (keyName.equals("VK_0")) {
return Canvas.KEY_NUM0;
} else if (keyName.equals("VK_1")) {
return Canvas.KEY_NUM1;
} else if (keyName.equals("VK_2")) {
return Canvas.KEY_NUM2;
} else if (keyName.equals("VK_3")) {
return Canvas.KEY_NUM3;
} else if (keyName.equals("VK_4")) {
return Canvas.KEY_NUM4;
} else if (keyName.equals("VK_5")) {
return Canvas.KEY_NUM5;
} else if (keyName.equals("VK_6")) {
return Canvas.KEY_NUM6;
} else if (keyName.equals("VK_7")) {
return Canvas.KEY_NUM7;
} else if (keyName.equals("VK_8")) {
return Canvas.KEY_NUM8;
} else if (keyName.equals("VK_9")) {
return Canvas.KEY_NUM9;
} else if (keyName.equals("VK_MULTIPLY")) {
return Canvas.KEY_STAR;
} else if (keyName.equals("VK_MODECHANGE")) {
return Canvas.KEY_POUND;
} else {
try {
return Integer.parseInt(keyName);
} catch (NumberFormatException ex) {
return -1;
}
}
}