@Override protected void keyTyped(char par1, int par2) throws IOException { if(par2 == 203 || par2 == 200 || par2 == 201) // Left, Up, Page Up prevPage(); else if(par2 == 205 || par2 == 208 || par2 == 209) // Right, Down Page Down nextPage(); else if(par2 == 14 && !notesEnabled && searchField.getText().isEmpty()) // Backspace back(); else if(par2 == 199) { // Home mc.displayGuiScreen(new GuiLexicon()); ClientTickHandler.notifyPageChange(); } else if(par2 == 28 && entriesToDisplay.size() == 1) // Enter openEntry(0); if(!notesEnabled) { String search = searchField.getText(); searchField.textboxKeyTyped(par1, par2); if(!searchField.getText().equalsIgnoreCase(search)) updateAll(); } super.keyTyped(par1, par2); }
@Override public boolean mouseClicked( final int xPos, final int yPos, final int button ) { super.mouseClicked( xPos, yPos, button ); final boolean requiresFocus = this.isMouseIn( xPos, yPos ); if( !this.isFocused() ) { this.setFocused( requiresFocus ); } return true; }
@Override public void drawBG( final int offsetX, final int offsetY, final int mouseX, final int mouseY ) { this.bindTexture( "guis/quartzknife.png" ); this.drawTexturedModalRect( offsetX, offsetY, 0, 0, this.xSize, this.ySize ); this.name.drawTextBox(); }
@Override public void initGui() { super.initGui(); this.name = new GuiTextField( 0, this.fontRenderer, this.guiLeft + 24, this.guiTop + 32, 79, this.fontRenderer.FONT_HEIGHT ); this.name.setEnableBackgroundDrawing( false ); this.name.setMaxStringLength( 32 ); this.name.setTextColor( 0xFFFFFF ); this.name.setVisible( true ); this.name.setFocused( true ); }
private void buildAutoCompletes(GuiTextField inputField, GuiChat chat) { String leftOfCursor; if(inputField.getCursorPosition() == 0) leftOfCursor = ""; else leftOfCursor = inputField.getText().substring(0, inputField.getCursorPosition()); if(leftOfCursor.length() == 0 || leftOfCursor.charAt(0) == '/') return; completions = getNames(leftOfCursor); if(completions.isEmpty()) return; position = -1; //ReflectionHelper.setPrivateValue(GuiChat.class, chat, true, LibObfuscation.COMPLETE_FLAG); StringBuilder stringbuilder = new StringBuilder(); CompletionData data; for(Iterator<CompletionData> iterator = completions.iterator(); iterator.hasNext(); stringbuilder.append(data.string)) { data = iterator.next(); if(stringbuilder.length() > 0) stringbuilder.append(", "); } Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(new TextComponentString(stringbuilder.toString()), 1); isAutoCompleted = true; originalString = inputField.getText(); }
@Override public void onInitGui() { super.onInitGui(); if(!GuiLexicon.isValidLexiconGui(this)) { currentOpenLexicon = new GuiLexicon(); mc.displayGuiScreen(currentOpenLexicon); ClientTickHandler.notifyPageChange(); return; } buttonList.add(backButton = new GuiButtonBack(12, left + guiWidth / 2 - 8, top + guiHeight + 2)); buttonList.add(leftButton = new GuiButtonPage(13, left, top + guiHeight - 10, false)); buttonList.add(rightButton = new GuiButtonPage(14, left + guiWidth - 18, top + guiHeight - 10, true)); searchField = new GuiTextField(15, fontRenderer, left + guiWidth / 2 + 28, top + guiHeight + 6, 200, 10); searchField.setCanLoseFocus(false); searchField.setFocused(true); searchField.setEnableBackgroundDrawing(false); updateAll(); }
@Override public void init(int x, int y) { addSideButton(new SideButtonRedstoneMode(this, readerWriter.getRedstoneModeParameter())); add = addButton(x + 128, y + 15, 20, 20, "+"); remove = addButton(x + 150, y + 15, 20, 20, "-"); name = new GuiTextField(0, fontRenderer, x + 8 + 1, y + 20 + 1, 107, fontRenderer.FONT_HEIGHT); name.setEnableBackgroundDrawing(false); name.setVisible(true); name.setTextColor(16777215); name.setCanLoseFocus(true); name.setFocused(false); }
@Override public void initGui() { super.initGui(); this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 6 + 96, this.yes)); this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 6 + 96, this.no)); this.nameField = new GuiTextField(2, this.fontRenderer, this.width / 2 - 155 + 77, this.height / 6 + 70, 155, 12); this.nameField.setTextColor(-1); this.nameField.setDisabledTextColour(-1); this.nameField.setEnableBackgroundDrawing(true); this.nameField.setMaxStringLength(35); this.listLines.clear(); this.listLines.addAll(this.fontRenderer.listFormattedStringToWidth(this.text2, this.width - 50)); this.nameField.setText(sword_names[new Random().nextInt(sword_names.length)]); }
@Override protected void keyTyped(char par1, int par2) { if(textFieldAdd.isFocused()) { textFieldAdd.textboxKeyTyped(par1, par2); textFieldText = textFieldAdd.getText(); addButtonCheck(); } }
@Override public void initGui() { super.initGui(); String oldString = searchField != null ? searchField.getText() : ""; this.searchField = new GuiTextField(0, this.fontRenderer, this.guiLeft + selection.getX() + 89 + 36, selection.getY() + this.guiTop + 4, 80, this.fontRenderer.FONT_HEIGHT); this.searchField.setMaxStringLength(50); this.searchField.setEnableBackgroundDrawing(false); this.searchField.setTextColor(16777215); this.searchField.setText(oldString); }
public TextFieldComponent(IValueContainer.Entry entry) { super(entry.getId(), entry.getName()); textFieldLootTable = new GuiTextField(0, Minecraft.getMinecraft().fontRenderer, 0, 0, GuiEditValueContainer.WIDTH - GuiEditValueContainer.PADDING * 2, 20); textFieldLootTable.setMaxStringLength(256); if(entry.getValue() != null) { textFieldLootTable.setText(entry.getValue()); } }
@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); }
@Override public void initGui() { super.initGui(); addressNameField = new GuiTextField(0, this.fontRenderer, guiLeft + 44, guiTop + 39, 90, 14); addressNameField.setText(container.getAddress().getName()); addressNameField.setFocused(true); }
@Override public void onUpdate( final String field, final Object oldValue, final Object newValue ) { if( field.equals( "EmitterValue" ) ) { if( this.textField != null ) { this.textField.setText( String.valueOf( this.EmitterValue ) ); } } }
@Override void buildEntries() { entriesToDisplay.clear(); ILexicon lex = (ILexicon) stackUsed.getItem(); for(int i = history.size() - 1; i >= 0; i--) { LexiconEntry entry = history.get(i); if(lex.isKnowledgeUnlocked(stackUsed, entry.getKnowledgeType()) && I18n.format(entry.getUnlocalizedName()).toLowerCase().contains(searchField.getText().toLowerCase().trim())) entriesToDisplay.add(entry); } }
private void mouseClickedTextboxes(int mouseX, int mouseY, int btn) { for (GuiTextField txt : txtBoxes) { txt.mouseClicked(mouseX, mouseY, btn); if (btn == 0) {//basically left click boolean flag = mouseX >= this.guiLeft + txt.x && mouseX < this.guiLeft + txt.x + txt.width && mouseY >= this.guiTop + txt.y && mouseY < this.guiTop + txt.y + txt.height; txt.setFocused(flag); } } }
@Override protected void keyTyped(char key, int keyID) { if (keyID == Keyboard.KEY_ESCAPE) { this.mc.player.closeScreen(); } this.searchbar.textboxKeyTyped(key, keyID); updateFluids(); }
public TextFieldWidget(int xPosition, int yPosition, int width, int height, boolean enableBackground, Supplier<String> textSupplier, Consumer<String> textResponder) { super(); if(isClientSide()) { FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer; this.textField = new GuiTextField(0, fontRenderer, xPosition, yPosition, width, height); this.textField.setCanLoseFocus(true); this.textField.setEnableBackgroundDrawing(enableBackground); this.textField.setMaxStringLength(maxStringLength); this.textField.setGuiResponder(MCGuiUtil.createTextFieldResponder(this::onTextChanged)); } this.textSupplier = textSupplier; this.textResponder = textResponder; }
@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); }