Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello, thank you for taking the time to read my question.

 

I have a GUI that I only want to display when a key is being pressed, a lot like a pie menu. I've tried using the Keybinding class and using the Keybinding ::isPressed() method, but when a GUI is open it stops registering as pressed.
How can I go about detecting if a key is pressed inside of a Gui? Preferably a key that is defined by a registered Keybinding so it's configurable.

 

Thank you.

Edited by ConsumerJunk

  • Author

Funny how life works sometimes. I spent 3 days stumped on this question, then within 10 minutes of asking it here I found the answer.
To avoid being the person who says they found the answer but fails to mention it in case people in the future have the same question:

 

Inside of the Gui class in the render function (known as func_230430_a_ right now) I run this check, see if the current screen is null, if
it's not null see if the gui is an instance of the custom Gui class, and if it run Minecraft::displayGuiScreen(null). (It probably doesn't need
the checks to see if the screen is null because it the code is running then that means the screen isn't, but I think it's important to have that
edge case, no matter how inconceivable, covered.

InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), someKeybinding.getKey().getKeyCode())

Edited by ConsumerJunk

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.