本文整理匯總了Java中org.lwjgl.input.Keyboard.KEY_DELETE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.KEY_DELETE屬性的具體用法?Java Keyboard.KEY_DELETE怎麽用?Java Keyboard.KEY_DELETE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.lwjgl.input.Keyboard
的用法示例。
在下文中一共展示了Keyboard.KEY_DELETE屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: keyTyped
@Override
protected void keyTyped(char c, int key) throws IOException {
if (Widget.getFocused() == null) {
if (key == Keyboard.KEY_ESCAPE || !justOpened && key == menuKey && key != Keyboard.KEY_NONE) {
super.keyTyped(c, Keyboard.KEY_ESCAPE);
} else if (key == Keyboard.KEY_DELETE) {
Widget widget = Widget.getHovered();
if (isElement(widget)) {
widget.setActivated(true);
widget.setValue(null);
}
}
} else {
Widget.getFocused().keyTyped(c, key);
}
}
示例2: keyTyped
@Override
protected void keyTyped(char key, int keyCode) throws IOException {
super.keyTyped(key, keyCode);
if (nameField.isFocused()) {
return;
}
if (Keyboard.KEY_I == keyCode && Loader.isModLoaded(ModIds.IGWMOD)) {
onIGWAction();
}
if (Keyboard.KEY_R == keyCode) {
if (exportButton.getBounds().contains(lastMouseX, lastMouseY)) {
NetworkHandler.sendToServer(new PacketGuiButton(0));
}
}
if (Keyboard.KEY_SPACE == keyCode) {
toggleShowWidgets();
}
if (Keyboard.KEY_DELETE == keyCode) {
IProgWidget widget = programmerUnit.getHoveredWidget(lastMouseX, lastMouseY);
if (widget != null) {
te.progWidgets.remove(widget);
NetworkHandler.sendToServer(new PacketProgrammerUpdate(te));
}
}
if (Keyboard.KEY_Z == keyCode) {
NetworkHandler.sendToServer(new PacketGuiButton(undoButton.id));
}
if (Keyboard.KEY_Y == keyCode) {
NetworkHandler.sendToServer(new PacketGuiButton(redoButton.id));
}
}
示例3: keyTyped
@Override
protected void keyTyped(char c, int i)
{
if (i == 1)
{
mc.displayGuiScreen(null);
mc.setIngameFocus();
}
if(i == Keyboard.KEY_DELETE && index >= 0 && index < channels.size())
{
channels.remove(index);
index--;
}
}
示例4: 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()));
}
}
}
}
示例5: 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++;
}
}
}
示例6: 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
}
}
示例7: 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;
}
}
示例8: 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;
}
}
示例9: 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);
}