@Override void handleKeyInput(char ch, int kid) { if (ChatAllowedCharacters.isAllowedCharacter(ch)) { pass = pass + ch; } else if (kid == Keyboard.KEY_RETURN) { State state = new StateNotify("s1_1"); setState(state); Syncs.authorizeMatrix( matrix, pass, Future.create( (Object o) -> { if (state == FreqTransmitterUI.this.current) { boolean result = (boolean) o; if (result) { setState(new StateDoMatrixLink(matrix, pass)); } else { setState(new StateNotifyAndQuit("e1")); } } })); } else if (kid == Keyboard.KEY_BACK) { if (pass.length() > 0) pass = pass.substring(0, pass.length() - 1); } }
/** Processes keystrokes when editing the text of a book */ private boolean keyTypedInBook(char par1, int par2) { switch (par1) { case 22: // Ctrl + V if (im.reset()) { current = current + im.getCommited(); preedit = ""; this.setText(current); } return true; default: switch (par2) { case Keyboard.KEY_BACK: if (im.delete()) { preedit = im.getPreedit(); this.setText(current + preedit); } else { if (current.length() > 0) { current = current.substring(0, current.length() - 1); this.setText(current); } } break; case Keyboard.KEY_RETURN: case Keyboard.KEY_NUMPADENTER: if (im.reset()) { current = current + im.getCommited(); preedit = ""; } if (current.length() < 256) { current = current + "\n"; } this.setText(current); break; default: if (ChatAllowedCharacters.isAllowedCharacter(par1)) { if (im.input(par1, isShiftKeyDown())) { current = current + im.getCommited(); } int i = this.fontRendererObj.splitStringWidth( current + "" + EnumChatFormatting.BLACK + "_", 118); if (i <= 118 && current.length() < 256) { preedit = im.getPreedit(); } else { if (im.reset()) { im.getCommited(); } preedit = ""; } this.setText(current + preedit); } } } return false; }
private boolean keyTypedInTitle(char par1, int par2) { switch (par2) { case Keyboard.KEY_BACK: if (im.delete()) { preedit = im.getPreedit(); setBookTitle(current + preedit); } else { return true; } break; case Keyboard.KEY_RETURN: case Keyboard.KEY_NUMPADENTER: if (im.reset()) { current = current + im.getCommited(); preedit = ""; this.setBookTitle(current); } return true; default: if (current.length() < 16 && ChatAllowedCharacters.isAllowedCharacter(par1)) { if (im.input(par1, isShiftKeyDown())) { current = current + im.getCommited(); } if (current.length() < 16) { preedit = im.getPreedit(); } else { if (im.reset()) { im.getCommited(); } preedit = ""; } this.setBookTitle(current + preedit); return true; } } return false; }
public boolean keyTyped(char character, int key) { if (getTextField() != null) { if (key == 203) { cursorLeft(1); } else if (key == 205) { cursorRight(1); } else if (character == 22) { add(GuiScreen.getClipboardString()); } else if (key == 14) { delete(-1); } else if (key == 211) { delete(0); } else if (key == 28 || key == 156) { add("\n"); } else if (ChatAllowedCharacters.isAllowedCharacter(character)) { add(Character.toString(character)); } } return false; }
/** Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e). */ protected void keyTyped(char p_73869_1_, int p_73869_2_) { if (p_73869_2_ == 200) { this.editLine = this.editLine - 1 & 3; } if (p_73869_2_ == 208 || p_73869_2_ == 28 || p_73869_2_ == 156) { this.editLine = this.editLine + 1 & 3; } if (p_73869_2_ == 14 && this.tileSign.signText[this.editLine].length() > 0) { this.tileSign.signText[this.editLine] = this.tileSign.signText[this.editLine].substring( 0, this.tileSign.signText[this.editLine].length() - 1); } if (ChatAllowedCharacters.isAllowedCharacter(p_73869_1_) && this.tileSign.signText[this.editLine].length() < 15) { this.tileSign.signText[this.editLine] = this.tileSign.signText[this.editLine] + p_73869_1_; } if (p_73869_2_ == 1) { this.actionPerformed(this.doneBtn); } }
/** Call this method from you GuiScreen to process the keys into textbox. */ public boolean textboxKeyTyped(char par1, int par2) { if (this.isEnabled && this.isFocused) { switch (par1) { case 1: this.setCursorPositionEnd(); this.setSelectionPos(0); return true; case 3: GuiScreen.setClipboardString(this.getSelectedtext()); return true; case 22: this.writeText(GuiScreen.getClipboardString()); return true; case 24: GuiScreen.setClipboardString(this.getSelectedtext()); this.writeText(""); return true; default: switch (par2) { case 14: if (GuiScreen.isCtrlKeyDown()) { this.deleteWords(-1); } else { this.deleteFromCursor(-1); } return true; case 199: if (GuiScreen.isShiftKeyDown()) { this.setSelectionPos(0); } else { this.setCursorPositionZero(); } return true; case 203: if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.setSelectionPos(this.getNthWordFromPos(-1, this.getSelectionEnd())); } else { this.setSelectionPos(this.getSelectionEnd() - 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.setCursorPosition(this.getNthWordFromCursor(-1)); } else { this.moveCursorBy(-1); } return true; case 205: if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.setSelectionPos(this.getNthWordFromPos(1, this.getSelectionEnd())); } else { this.setSelectionPos(this.getSelectionEnd() + 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.setCursorPosition(this.getNthWordFromCursor(1)); } else { this.moveCursorBy(1); } return true; case 207: if (GuiScreen.isShiftKeyDown()) { this.setSelectionPos(this.text.length()); } else { this.setCursorPositionEnd(); } return true; case 211: if (GuiScreen.isCtrlKeyDown()) { this.deleteWords(1); } else { this.deleteFromCursor(1); } return true; default: if (ChatAllowedCharacters.isAllowedCharacter(par1)) { this.writeText(Character.toString(par1)); return true; } else { return false; } } } } else { return false; } }
/** Call this method from your GuiScreen to process the keys into the textbox */ public boolean textboxKeyTyped(char p_146201_1_, int p_146201_2_) { if (!this.field_146213_o) { return false; } else { switch (p_146201_1_) { case 1: this.func_146202_e(); this.func_146199_i(0); return true; case 3: GuiScreen.setClipboardString(this.func_146207_c()); return true; case 22: if (this.field_146226_p) { this.func_146191_b(GuiScreen.getClipboardString()); } return true; case 24: GuiScreen.setClipboardString(this.func_146207_c()); if (this.field_146226_p) { this.func_146191_b(""); } return true; default: switch (p_146201_2_) { case 14: if (GuiScreen.isCtrlKeyDown()) { if (this.field_146226_p) { this.func_146177_a(-1); } } else if (this.field_146226_p) { this.func_146175_b(-1); } return true; case 199: if (GuiScreen.isShiftKeyDown()) { this.func_146199_i(0); } else { this.func_146196_d(); } return true; case 203: if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.func_146199_i(this.func_146183_a(-1, this.func_146186_n())); } else { this.func_146199_i(this.func_146186_n() - 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.func_146190_e(this.func_146187_c(-1)); } else { this.func_146182_d(-1); } return true; case 205: if (GuiScreen.isShiftKeyDown()) { if (GuiScreen.isCtrlKeyDown()) { this.func_146199_i(this.func_146183_a(1, this.func_146186_n())); } else { this.func_146199_i(this.func_146186_n() + 1); } } else if (GuiScreen.isCtrlKeyDown()) { this.func_146190_e(this.func_146187_c(1)); } else { this.func_146182_d(1); } return true; case 207: if (GuiScreen.isShiftKeyDown()) { this.func_146199_i(this.field_146216_j.length()); } else { this.func_146202_e(); } return true; case 211: if (GuiScreen.isCtrlKeyDown()) { if (this.field_146226_p) { this.func_146177_a(1); } } else if (this.field_146226_p) { this.func_146175_b(1); } return true; default: if (ChatAllowedCharacters.isAllowedCharacter(p_146201_1_)) { if (this.field_146226_p) { this.func_146191_b(Character.toString(p_146201_1_)); } return true; } else { return false; } } } } }
public boolean isAllowedCharacter(char charTyped) { return ChatAllowedCharacters.isAllowedCharacter(charTyped); }