當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。