Frontear Posted November 21, 2018 Posted November 21, 2018 (edited) Effectively, here is the code I've currently been working with: Main Class: @SubscribeEvent public void onGuiScreen(GuiOpenEvent event) { InputMenu menu; if (event.gui instanceof GuiMainMenu) { menu = new InputMenu(event.gui); event.gui = menu; } } InputMenu Class: public class InputMenu extends GuiScreen { private GuiTextField inputField; private GuiScreen previousScreen; public InputMenu(GuiScreen previousScreen) { this.previousScreen = previousScreen; // save the main menu to return to later } @Override public void initGui() { inputField = new GuiTextField(-1, fontRendererObj ...); } @Override public void drawScreen(int mouseX, int mouseY, float partialTicks) { inputField.drawTextBox(); inputField.setFocused(true); } @Override public void updateScreen() { inputField.updateCursorCounter(); } @Override protected void keyTyped(char typedChar, int keyCode) throws IOException { if (keyCode == Keyboard.KEY_RETURN) { // go back to menu HandleInput(); mc.displayGuiScreen(previousScreen); // doesn't work } inputField.textboxKeyTyped(typedChar, keyCode); } } This isn't returning to the main menu, but is instead staying on the InputMenu screen, and only resetting the textField to empty characters upon pressing enter. I can't get it to return, even though I have set the mc.displayGuiScreen correctly. What might be the issue? EDIT: SOLVED The issue was that GuiOpenEvent got called when I tried to go back to the MainMenu, which, according to my old conditionals, would just display the InputMenu again. Adding a boolean fixed this, by checking if the user has already seen this menu before Edited November 21, 2018 by Frontear Quote I am a human and this action was performed manually. Please contact Frontear if you have any questions or concerns.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.