本文整理匯總了Java中org.lwjgl.input.Keyboard.CHAR_NONE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.CHAR_NONE屬性的具體用法?Java Keyboard.CHAR_NONE怎麽用?Java Keyboard.CHAR_NONE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.lwjgl.input.Keyboard
的用法示例。
在下文中一共展示了Keyboard.CHAR_NONE屬性的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: keyTyped
@Override
public void keyTyped(char c, int key) {
if (key == Keyboard.KEY_ESCAPE || key == Keyboard.KEY_RETURN) {
setFocused(false);
} else {
String value = (String) getValue();
if (key == Keyboard.KEY_BACK) {
if (cursor == 0) return;
--cursor;
setValue(value.substring(0, cursor)
+value.substring(cursor+1,value.length()));
} else if (key == Keyboard.KEY_DELETE) {
if (cursor == value.length()) return;
setValue(value.substring(0, cursor)
+value.substring(cursor+1,value.length()));
} else if (key == Keyboard.KEY_HOME) {
cursor = 0;
} else if (key == Keyboard.KEY_END) {
cursor = value.length();
} else if (key == Keyboard.KEY_LEFT) {
if (cursor > 0) --cursor;
} else if (key == Keyboard.KEY_RIGHT) {
if (cursor < value.length()) ++cursor;
} else if (c != Keyboard.CHAR_NONE) {
setValue(value.substring(0, cursor)+c
+value.substring(cursor,value.length()));
++cursor;
}
// TODO: selection, ^X, ^C, ^V
}
}