本文整理汇总了Java中org.lwjgl.input.Keyboard.KEY_BACK属性的典型用法代码示例。如果您正苦于以下问题:Java Keyboard.KEY_BACK属性的具体用法?Java Keyboard.KEY_BACK怎么用?Java Keyboard.KEY_BACK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.lwjgl.input.Keyboard
的用法示例。
在下文中一共展示了Keyboard.KEY_BACK属性的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: keyTyped
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (keyCode == Keyboard.KEY_DELETE || keyCode == Keyboard.KEY_BACK) {
if (lastSelected != -1) {
ItemStack heldItem = PortalGunItem.getGun(mc.player);
List<TeleportDestination> destinations = PortalGunItem.getDestinations(heldItem);
if (destinations.get(lastSelected) != null) {
MeeCreepsMessages.INSTANCE.sendToServer(new PacketSendServerCommand(MeeCreeps.MODID, CommandHandler.CMD_DELETE_DESTINATION, Arguments.builder().value(lastSelected).build()));
}
}
}
}
示例2: keyTyped
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (keyCode == Keyboard.KEY_BACK) {
if (!text.isEmpty() && cursor > 0) {
text = text.substring(0, cursor-1) + text.substring(cursor);
cursor--;
}
} else if (keyCode == Keyboard.KEY_DELETE) {
if (cursor < text.length()) {
text = text.substring(0, cursor) + text.substring(cursor+1);
}
} else if (keyCode == Keyboard.KEY_HOME) {
cursor = 0;
} else if (keyCode == Keyboard.KEY_END) {
cursor = text.length();
} else if (keyCode == Keyboard.KEY_LEFT) {
if (cursor > 0) {
cursor--;
}
} else if (keyCode == Keyboard.KEY_RIGHT) {
if (cursor < text.length()) {
cursor++;
}
} else if (keyCode == Keyboard.KEY_ESCAPE) {
close();
} else if (keyCode == Keyboard.KEY_RETURN) {
destination = new TeleportDestination(text, destination.getDimension(), destination.getPos(), destination.getSide());
MeeCreepsMessages.INSTANCE.sendToServer(new PacketSetDestination(destination, destinationIndex));
close();
} else if (typedChar != 0) {
if (text.length() < 15) {
text = text.substring(0, cursor) + typedChar + text.substring(cursor);
cursor++;
}
}
}
示例3: keyTyped
public void keyTyped(char typedChar, int keyCode) throws IOException {
if (isActive) {
switch (keyCode) {
case Keyboard.KEY_ESCAPE:
isActive = false;
break;
case Keyboard.KEY_RETURN:
isActive = false;
//setValue(input);
MC.player.sendMessage(new TextComponentString(input.toString()));
break;
case Keyboard.KEY_BACK:
if (selectedIndex > -1) {
input.deleteCharAt(selectedIndex);
selectedIndex--;
}
break;
case Keyboard.KEY_LEFT:
selectedIndex--;
break;
case Keyboard.KEY_RIGHT:
selectedIndex++;
break;
default:
if (isValidChar(typedChar)) {
selectedIndex++;
input.insert(selectedIndex, typedChar);
}
}
selectedIndex = MathHelper.clamp(selectedIndex, -1, input.length()-1);
}
}
示例4: keyPress
@Override
public void keyPress(int key, char keyChar) {
if (!focus) return;
if (key == Keyboard.KEY_RETURN) {
if (text.replaceAll(" ", "") == "") return;
String[] arr = text.split(" ");
String command = arr[0];
String[] args = Arrays.copyOfRange(arr, 1, arr.length);
Bit.getInstance().getCommandManager().processCommand(command, args);
Bit.getInstance().nullString(lastCommand);
lastCommand = text;
Bit.getInstance().nullString(text);
text = "";
return;
} else if (key == Keyboard.KEY_BACK) {
if (text.length() - 1 >= 0) text = text.substring(0, text.length() - 1);
return;
} else if (lastCommand != null && !lastCommand.equals("") && key == Keyboard.KEY_UP) {
text = lastCommand;
return;
}
if (Wrapper.getStringWidth_scaled(text, 0.5) > this.getSize().getX() - 9) return;
String keyName = String.valueOf(keyChar);
if (keyName.length() != 1) return;
if (Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)) keyName = keyName.toUpperCase();
text += keyName;
}
示例5: keyTyped
@Override
public void keyTyped(char c, int key)
{
if (c >= '0' && c <= '9')
{
amount = amount.concat("" + c);
}
if (key == Keyboard.KEY_BACK && amount != null && !amount.isEmpty()) {
amount = amount.substring(0, amount.length() - 1);
}
if (key == Keyboard.KEY_RETURN) {
AccountCapability cap = player.getCapability(Currency.ACCOUNT_DATA, null);
if (amount != null && !amount.isEmpty() && Float.parseFloat(amount) <= 25000) {
if (!deposit.enabled) {
cap.addClientAmount(Float.parseFloat(amount), true);
CurrencyUtils.depositMoney(player, Float.parseFloat(amount));
} else if (!withdraw.enabled && Float.parseFloat(amount) <= cap.getAmount()) {
cap.subtractClientAmount(Float.parseFloat(amount), true);
PacketDispatcher.sendToServer(new MessageSyncDrops(player, Float.parseFloat(amount)));
}
}
this.mc.displayGuiScreen((GuiScreen)null);
}
if (key == Keyboard.KEY_E || key == Keyboard.KEY_ESCAPE) {
this.mc.displayGuiScreen((GuiScreen)null);
}
if (key == Keyboard.KEY_UP || key == Keyboard.KEY_DOWN) {
withdraw.enabled = !withdraw.enabled;
deposit.enabled = !deposit.enabled;
}
}
示例6: keyTyped
@Override
public void keyTyped(char c, int key) {
if (c >= '0' && c <= '9') {
if (!amount.contains(".") || amount.contains(".") && amount.substring(amount.lastIndexOf(".")).length() < 3) {
System.out.println("WHAT");
amount = amount.concat("" + c);
}
}
if (c == '.') {
if (!amount.isEmpty() && !amount.contains(".")) {
amount = amount.concat("" + c);
} else if (amount.isEmpty()) {
amount = amount.concat("0" + c);
}
}
if (key == Keyboard.KEY_BACK && amount != null && !amount.isEmpty()) {
amount = amount.substring(0, amount.length() - 1);
}
if (key == Keyboard.KEY_RETURN) {
AccountCapability cap = player.getCapability(Currency.ACCOUNT_DATA, null);
if (amount != null && !amount.isEmpty() && Float.parseFloat(amount) <= 100000) {
// if (!deposit.enabled) {
// cap.addClientAmount(Float.parseFloat(amount), true);
// CurrencyUtils.depositMoney(player, Float.parseFloat(amount));
// } else if (!withdraw.enabled && Float.parseFloat(amount) <=
// cap.getAmount()) {
// cap.subtractClientAmount(Float.parseFloat(amount), true);
// PacketDispatcher.sendToServer(new MessageSyncDrops(player,
// Float.parseFloat(amount)));
// }
}
this.mc.displayGuiScreen((GuiScreen) null);
}
if (key == Keyboard.KEY_E || key == Keyboard.KEY_ESCAPE) {
this.mc.displayGuiScreen((GuiScreen) null);
}
}
示例7: keyUp
@Override
public void keyUp(int keycode)
{
if (keycode == Keyboard.KEY_BACK || keycode == Keyboard.KEY_Q)
{
goBack();
}
}
示例8: 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
}
}
示例9: keyTyped
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException {
super.keyTyped(typedChar, keyCode);
if (keyCode == Keyboard.KEY_SPACE || keyCode == Keyboard.KEY_RIGHT) {
pageInc();
} else if (keyCode == Keyboard.KEY_LEFT || keyCode == Keyboard.KEY_BACK) {
pageDec();
} else if (keyCode == Keyboard.KEY_HOME) {
pageFront();
}
}
示例10: keyTyped
@Override
protected void keyTyped(char typedChar, int keyCode) throws IOException
{
if (keyCode == mc.gameSettings.keyBindInventory.getKeyCode() || keyCode == Keyboard.KEY_RETURN || keyCode == UHCCompass.instance.keyHandler.getKeyCode(KeyHandler.QUICKCOORDS))
{
try{
int x = Integer.parseInt(xCoord.getText());
int z = Integer.parseInt(zCoord.getText());
UHCCompass.TARGETX_PROPERTY.set(x);
UHCCompass.TARGETZ_PROPERTY.set(z);
}catch(Exception e){
mc.player.sendMessage(new TextComponentTranslation("uhccompass.invalidcoords"));
}
UHCCompass.syncConfig();
this.mc.displayGuiScreen(null);
if (this.mc.currentScreen == null)
{
this.mc.setIngameFocus();
}
} else if(keyCode == Keyboard.KEY_TAB || keyCode == Keyboard.KEY_SPACE){
xCoord.setFocused(!xCoord.isFocused());
zCoord.setFocused(!zCoord.isFocused());
}else if(Character.isDigit(typedChar) || typedChar == '-' || keyCode == Keyboard.KEY_BACK || keyCode == Keyboard.KEY_LEFT || keyCode == Keyboard.KEY_RIGHT){
xCoord.textboxKeyTyped(typedChar, keyCode);
zCoord.textboxKeyTyped(typedChar, keyCode);
}else if (keyCode == 201)
{
this.mc.ingameGUI.getChatGUI().scroll(this.mc.ingameGUI.getChatGUI().getLineCount() - 1);
}
else if (keyCode == 209)
{
this.mc.ingameGUI.getChatGUI().scroll(-this.mc.ingameGUI.getChatGUI().getLineCount() + 1);
}
super.keyTyped(typedChar, keyCode);
}
示例11: keyTyped
@Override
public void keyTyped(char eventChar, int eventKey)
{
if (enabled() || eventKey == Keyboard.KEY_LEFT || eventKey == Keyboard.KEY_RIGHT || eventKey == Keyboard.KEY_HOME || eventKey == Keyboard.KEY_END)
{
String validChars = "0123456789";
String before = this.textFieldValue.getText();
if (validChars.contains(String.valueOf(eventChar))
|| (!before.startsWith("-") && this.textFieldValue.getCursorPosition() == 0 && eventChar == '-')
|| eventKey == Keyboard.KEY_BACK || eventKey == Keyboard.KEY_DELETE
|| eventKey == Keyboard.KEY_LEFT || eventKey == Keyboard.KEY_RIGHT || eventKey == Keyboard.KEY_HOME || eventKey == Keyboard.KEY_END)
this.textFieldValue.textboxKeyTyped((enabled() ? eventChar : Keyboard.CHAR_NONE), eventKey);
if (!textFieldValue.getText().trim().isEmpty() && !textFieldValue.getText().trim().equals("-"))
{
try
{
long value = Long.parseLong(textFieldValue.getText().trim());
if (value < Integer.valueOf(configElement.getMinValue().toString()) || value > Integer.valueOf(configElement.getMaxValue().toString()))
this.isValidValue = false;
else
this.isValidValue = true;
}
catch (Throwable e)
{
this.isValidValue = false;
}
}
else
this.isValidValue = false;
}
}
示例12: keyTyped
@Override
public void keyTyped(char eventChar, int eventKey)
{
if (owningScreen.enabled || eventKey == Keyboard.KEY_LEFT || eventKey == Keyboard.KEY_RIGHT
|| eventKey == Keyboard.KEY_HOME || eventKey == Keyboard.KEY_END)
{
String validChars = "0123456789";
String before = this.textFieldValue.getText();
if (validChars.contains(String.valueOf(eventChar)) ||
(!before.startsWith("-") && this.textFieldValue.getCursorPosition() == 0 && eventChar == '-')
|| (!before.contains(".") && eventChar == '.')
|| eventKey == Keyboard.KEY_BACK || eventKey == Keyboard.KEY_DELETE || eventKey == Keyboard.KEY_LEFT || eventKey == Keyboard.KEY_RIGHT
|| eventKey == Keyboard.KEY_HOME || eventKey == Keyboard.KEY_END)
this.textFieldValue.textboxKeyTyped((owningScreen.enabled ? eventChar : Keyboard.CHAR_NONE), eventKey);
if (!textFieldValue.getText().trim().isEmpty() && !textFieldValue.getText().trim().equals("-"))
{
try
{
double value = Double.parseDouble(textFieldValue.getText().trim());
if (value < Double.valueOf(configElement.getMinValue().toString()) || value > Double.valueOf(configElement.getMaxValue().toString()))
this.isValidValue = false;
else
this.isValidValue = true;
}
catch (Throwable e)
{
this.isValidValue = false;
}
}
else
this.isValidValue = false;
}
}
示例13: handleKeyTyped
public void handleKeyTyped(char key, int code) {
if (c instanceof BrowserView) {
BrowserView view = (BrowserView) c;
switch (code) {
case(Keyboard.KEY_BACK):
SwingUtils.forwardKeyTypedEvent(view.getBrowser(), KeyCode.VK_BACK);
break;
default:
SwingUtils.forwardKeyTypedEvent(view.getBrowser(), key);
break;
}
}
}
示例14: keyTyped
@Override
protected void keyTyped(char par1, int par2) throws IOException {
if (par2 == Keyboard.KEY_ESCAPE) {
NetworkHandler.sendToServer(new PacketAphorismTileUpdate(tile));
} else if (par2 == Keyboard.KEY_LEFT || par2 == Keyboard.KEY_UP) {
cursorY--;
if (cursorY < 0) cursorY = textLines.length - 1;
} else if (par2 == Keyboard.KEY_DOWN || par2 == Keyboard.KEY_NUMPADENTER) {
cursorY++;
if (cursorY >= textLines.length) cursorY = 0;
} else if (par2 == Keyboard.KEY_RETURN) {
cursorY++;
textLines = ArrayUtils.add(textLines, cursorY, "");
} else if (par2 == Keyboard.KEY_BACK) {
if (textLines[cursorY].length() > 0) {
textLines[cursorY] = textLines[cursorY].substring(0, textLines[cursorY].length() - 1);
if (textLines[cursorY].endsWith("\u00a7")) {
textLines[cursorY] = textLines[cursorY].substring(0, textLines[cursorY].length() - 1);
}
} else if (textLines.length > 1) {
textLines = ArrayUtils.remove(textLines, cursorY);
cursorY--;
if (cursorY < 0) cursorY = 0;
}
} else if (par2 == Keyboard.KEY_DELETE) {
if (GuiScreen.isShiftKeyDown()) {
textLines = new String[1];
textLines[0] = "";
cursorY = 0;
} else {
if (textLines.length > 1) {
textLines = ArrayUtils.remove(textLines, cursorY);
if (cursorY > textLines.length - 1)
cursorY = textLines.length - 1;
}
}
} else if (ChatAllowedCharacters.isAllowedCharacter(par1)) {
if (GuiScreen.isAltKeyDown()) {
if (par1 >= 'a' && par1 <= 'f' || par1 >= 'l' && par1 <= 'o' || par1 == 'r' || par1 >= '0' && par1 <= '9') {
textLines[cursorY] = textLines[cursorY] + "\u00a7" + par1;
}
} else {
textLines[cursorY] = textLines[cursorY] + par1;
}
}
tile.setTextLines(textLines);
super.keyTyped(par1, par2);
}