void updateFocusField() { textFields.forEach((field) -> { if(field.isFocused()) focusedField = field.getId(); }); }
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { boolean prevFocused = false; boolean postFocused = false; for (GuiTextField text : textFields) { prevFocused = text.isFocused() || prevFocused; text.mouseClicked(mouseX, mouseY, mouseButton); postFocused = text.isFocused() || postFocused; } if (prevFocused && !postFocused) { updateServer(); } }
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { // super.mouseClicked(mouseX,mouseY,mouseButton); boolean prevFocused = false; boolean postFocused = false; for (GuiTextField text : textFields) { prevFocused = text.isFocused() || prevFocused; text.mouseClicked(mouseX, mouseY, mouseButton); postFocused = text.isFocused() || postFocused; } if (prevFocused && !postFocused) { updateServer(); } }
protected boolean isSearchFieldFocussed() { return getSearchField().isFocused(); }
@Override public void onPageRightButtonPressed(){ this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage+1, this.searchText, this.searchField.isFocused())); }
@Override public void onPageLeftButtonPressed(){ this.mc.displayGuiScreen(new GuiEntry(this.previousScreen, this.parentPage, this.entry, this.entryPage-1, this.searchText, this.searchField.isFocused())); }
@Override protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException { super.mouseClicked(mouseX, mouseY, mouseButton); int currentFocus = focusedField; textFields.forEach((field) -> field.mouseClicked(mouseX, mouseY, mouseButton)); updateFocusField(); if(focusedField == currentFocus && !textFields.get(focusedField).isFocused()) textFields.get(focusedField).setFocused(true); }
@Override protected void keyTyped(char eventCharacter, int eventKey) throws IOException { // Set focus or enter text into address if (addressNameField.isFocused()) { if (eventKey == Keyboard.KEY_RETURN) { setAddress(); } else { addressNameField.textboxKeyTyped(eventCharacter, eventKey); } return; } super.keyTyped(eventCharacter, eventKey); }
private boolean isContainerTextFieldFocused() { GuiScreen gui = Minecraft.getMinecraft().currentScreen; if (gui == null) { return false; } GuiTextField textField = ReflectionUtil.getFieldWithClass(gui, GuiTextField.class); return textField != null && textField.getVisible() && textField.isFocused(); }
@Override protected void keyTyped(char par1, int par2) { if(textFieldAdd.isFocused()) { textFieldAdd.textboxKeyTyped(par1, par2); textFieldText = textFieldAdd.getText(); addButtonCheck(); } }
@Override public void keyTyped(char theChar, int key) throws IOException{ if(key != 1 && this.nameField.isFocused()){ if(key == Keyboard.KEY_RETURN || key == Keyboard.KEY_NUMPADENTER){ this.setVariable(this.nameField); } else{ this.nameField.textboxKeyTyped(theChar, key); } } else{ super.keyTyped(theChar, key); } }
@Override public void mouseClicked(int i, int j, int k) { if (isMouseOverTextField(textFieldAddTrustedPlayer, i, j)) { if (textFieldAddTrustedPlayer.isFocused()) { textFieldAddTrustedPlayer.mouseClicked(i, j, k); } else { textFieldAddTrustedPlayer.setFocused(true); } } else { try { super.mouseClicked(i, j, k); } catch (IOException e) { e.printStackTrace(); } } }
@SuppressWarnings("EmptyCatchBlock") @Override protected void keyTyped(char typedChar, int keyCode) { if (textFieldAddTrustedPlayer == null || !textFieldAddTrustedPlayer.isFocused()) { try { super.keyTyped(typedChar, keyCode); } catch (IOException e) { } } else if (textFieldAddTrustedPlayer != null) { if (typedChar != 27) { textFieldAddTrustedPlayer.textboxKeyTyped(typedChar, keyCode); } else { textFieldAddTrustedPlayer.setFocused(false); } } }
@Override protected void keyTyped(char i, int j) { this.tbName.textboxKeyTyped(i, j); if (j == 1) { // esc this.mc.player.closeScreen(); return; } if (this.tbName.isFocused()) { if (j == 28) { // enter playClickSound(0.7F); } } updateButtons(); }
@Override protected void keyTyped(char typedChar, int key) throws IOException{ if(key == Keyboard.KEY_ESCAPE || (key == this.mc.gameSettings.keyBindInventory.getKeyCode() && (!this.hasSearchBar() || !this.searchField.isFocused()))){ this.mc.displayGuiScreen(this.previousScreen); } else if(this.hasSearchBar() & this.searchField.isFocused()){ String lastText = this.searchField.getText(); this.searchField.textboxKeyTyped(typedChar, key); if(!lastText.equals(this.searchField.getText())){ this.onSearchBarChanged(this.searchField.getText()); } } else{ super.keyTyped(typedChar, key); } }
@Override protected void keyTyped(char character, int keyCode) throws IOException { if (keyCode == Keyboard.KEY_DELETE) { onRemove(); } else if (name.isFocused() && keyCode == Keyboard.KEY_RETURN) { onAdd(); } else if (!checkHotbarKeys(keyCode) && name.textboxKeyTyped(character, keyCode)) { // NO OP } else { super.keyTyped(character, keyCode); } }
@SubscribeEvent public void onKeypress(GuiScreenEvent.KeyboardInputEvent.Pre event) { if(searchBar != null && searchBar.isFocused() && Keyboard.getEventKeyState()) { char eventChar = Keyboard.getEventCharacter(); int eventCode = Keyboard.getEventKey(); searchBar.textboxKeyTyped(eventChar, eventCode); text = searchBar.getText(); event.setCanceled(eventCode != 1); } }
@Override protected void keyTyped(char typedChar, int keyCode) throws IOException { if (this.mc.gameSettings.keyBindInventory.isActiveAndMatches(keyCode) == false) { super.keyTyped(typedChar, keyCode); } if (txtPassword != null && txtPassword.isFocused()) { txtPassword.textboxKeyTyped(typedChar, keyCode); ModCyclic.network.sendToServer(new PacketTilePassword(PacketType.PASSTEXT, txtPassword.getText(), ctr.tile.getPos())); } }
@SubscribeEvent public void onMouseclick(GuiScreenEvent.MouseInputEvent.Pre event) { if(searchBar != null && Mouse.getEventButtonState()) { Minecraft mc = Minecraft.getMinecraft(); GuiScreen gui = event.getGui(); int x = Mouse.getEventX() * gui.width / mc.displayWidth; int y = gui.height - Mouse.getEventY() * gui.height / mc.displayHeight - 1; int button = Mouse.getEventButton(); searchBar.mouseClicked(x, y, button); long time = System.currentTimeMillis(); long delta = time - lastClick; if(delta < 200 && searchBar.isFocused()) { searchBar.setText(""); text = ""; } lastClick = time; } }
public void drawScreenPre(int mouseX, int mouseY, float partialTicks){ GlStateManager.color(1F, 1F, 1F); this.mc.getTextureManager().bindTexture(RES_LOC_GUI); drawModalRectWithCustomSizedTexture(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize, 512, 512); if(this.hasSearchBar()){ this.mc.getTextureManager().bindTexture(RES_LOC_GADGETS); this.drawTexturedModalRect(this.guiLeft+this.xSize, this.guiTop+this.ySize-40, 188, 0, 68, 14); boolean unicodeBefore = this.fontRenderer.getUnicodeFlag(); this.fontRenderer.setUnicodeFlag(true); if(!this.searchField.isFocused() && (this.searchField.getText() == null || this.searchField.getText().isEmpty())){ this.fontRenderer.drawString(TextFormatting.ITALIC+StringUtil.localize("info."+ActuallyAdditions.MODID+".booklet.searchField"), this.guiLeft+this.xSize+2, this.guiTop+this.ySize-40+2, 0xFFFFFF, false); } this.searchField.drawTextBox(); this.fontRenderer.setUnicodeFlag(unicodeBefore); } }