Curios API (Fabric)

Curios API (Fabric)

819k Downloads

[Bug]: Pressing G closes any active GUI

IchHabeHunger54 opened this issue ยท 5 comments

commented

Minecraft Version

1.20.4

What happened?

Pressing G in any GUI automatically closes said GUI. Noticed when debugging one of my mod's GUIs, which has a search bar. However, this also affects a number of other GUIs, for example the creative inventory.
After some investigation, this appears to specifically affect container-backed GUIs - chests and crafting tables are affected, but a written book GUI or one of my other modded GUIs (which is not container-backed) are not affected.
Also notably, the survival inventory is not affected either.

How do you trigger this bug?

  1. Open the creative inventory, or a chest, or a crafting table, or any other GUI with slots
  2. Press G
  3. Observe how the menu closes itself

Loader

NeoForge

Loader Version

NeoForge 20.4.198

Mod Version

Curios 7.3.2+1.20.4

Relevant Log Outputs

N/A

commented

This was a feature request, made here and by a couple others in the past: #352

Since that's the case, I need to carefully consider the right approach to this. Does this issue cause any problems that the regular "Open/Close Inventory" keybind does not?

commented

I noticed this specifically when using the search bar in my mod's GUI. I can type E freely, but I cannot type G, as this closes the GUI. I do not have any code to special-case E in that GUI.

commented

Are you sure this is not a bug in your mod's GUI? I only ask because I am trying to reproduce it and using the Curios keybinding does not close the GUI when typing in the Creative inventory search bar and the Anvil renaming field, however I am not sure if this is perhaps due to a different reason.

commented

Indeed, I can't reproduce it for the creative inventory either. Tell you what, I'll join the Discord and try to work it out there.

commented

Resolved on my end, issue was in the GUI code. For those who happen to read this, my problem was an incorrect return value in Screen#keyPressed. Make sure you always return true if an EditBox is currently focused, as that prevents further key handling (including the Curios event handler) from running.