TheIllusiveC4 / Curios

Minecraft Mod: A flexible and expandable accessory/equipment API for users and developers.
https://www.curseforge.com/minecraft/mc-mods/curios
Other
173 stars 66 forks source link

[Bug]: Pressing G closes any active GUI #393

Closed IchHabeHunger54 closed 2 months ago

IchHabeHunger54 commented 3 months ago

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

TheIllusiveC4 commented 3 months ago

This was a feature request, made here and by a couple others in the past: https://github.com/TheIllusiveC4/Curios/issues/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?

IchHabeHunger54 commented 3 months ago

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.

TheIllusiveC4 commented 2 months ago

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.

IchHabeHunger54 commented 2 months ago

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.

IchHabeHunger54 commented 2 months ago

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.