当前位置: 首页>>代码示例>>Java>>正文


Java Keyboard.KEY_BACK属性代码示例

本文整理汇总了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()));
            }
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:13,代码来源:GuiWheel.java

示例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++;
        }
    }
}
 
开发者ID:McJty,项目名称:MeeCreeps,代码行数:37,代码来源:GuiAskName.java

示例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);
    }
}
 
开发者ID:fr1kin,项目名称:ForgeHax,代码行数:37,代码来源:GuiTextInput.java

示例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;
}
 
开发者ID:Ygore,项目名称:bit-client,代码行数:28,代码来源:ConsoleComponent.java

示例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;
}
  }
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:31,代码来源:GuiATM.java

示例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);
	}
}
 
开发者ID:Zundrel,项目名称:Never-Enough-Currency,代码行数:38,代码来源:GuiStockCrate.java

示例7: keyUp

@Override
public void keyUp(int keycode)
{
    if (keycode == Keyboard.KEY_BACK || keycode == Keyboard.KEY_Q)
    {
        goBack();
    }
}
 
开发者ID:PearXTeam,项目名称:PurificatiMagicae,代码行数:8,代码来源:GuiIfTabletS.java

示例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
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:31,代码来源:TextField.java

示例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();
    }
}
 
开发者ID:McJty,项目名称:Lector,代码行数:11,代码来源:GuiManual.java

示例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);
}
 
开发者ID:The-Fireplace-Minecraft-Mods,项目名称:UHC-Compass,代码行数:37,代码来源:GuiCoords.java

示例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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:32,代码来源:GuiConfigEntries.java

示例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;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:34,代码来源:GuiEditArrayEntries.java

示例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;
		}
	}
}
 
开发者ID:lukas2005,项目名称:Device-Mod-Apps,代码行数:13,代码来源:SwingWrapper.java

示例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);
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:48,代码来源:GuiAphorismTile.java


注:本文中的org.lwjgl.input.Keyboard.KEY_BACK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。