Skip to content

Commit

Permalink
Fix hotkeys not working after resizing screen with a recipe open
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Jun 18, 2016
1 parent 118203a commit a4ff37b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Expand Up @@ -5,4 +5,4 @@ curse_project_id=238222

version_major=3
version_minor=6
version_patch=5
version_patch=6
12 changes: 8 additions & 4 deletions src/main/java/mezz/jei/GuiEventHandler.java
@@ -1,5 +1,8 @@
package mezz.jei;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import mezz.jei.config.Config;
import mezz.jei.gui.ItemListOverlay;
import mezz.jei.gui.RecipesGui;
Expand All @@ -14,9 +17,6 @@
import net.minecraftforge.fml.common.gameevent.TickEvent;
import org.lwjgl.input.Mouse;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class GuiEventHandler {
@Nonnull
private static final String showRecipesText = Translator.translateToLocal("jei.tooltip.show.recipes");
Expand All @@ -40,7 +40,11 @@ public void onGuiInit(@Nonnull GuiScreenEvent.InitGuiEvent.Post event) {

RecipesGui recipesGui = new RecipesGui();
inputHandler = new InputHandler(recipesGui, itemListOverlay);
} else if (!(gui instanceof RecipesGui)) {
} else if (gui instanceof RecipesGui) {
if (inputHandler != null) {
inputHandler.onScreenResized();
}
} else {
inputHandler = null;
}
}
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/mezz/jei/input/InputHandler.java
Expand Up @@ -5,18 +5,6 @@
import java.util.ArrayList;
import java.util.List;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiRepair;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.client.settings.KeyBinding;
import net.minecraft.item.ItemStack;

import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

import mezz.jei.Internal;
import mezz.jei.RecipeRegistry;
import mezz.jei.config.Config;
Expand All @@ -27,6 +15,15 @@
import mezz.jei.gui.RecipesGui;
import mezz.jei.util.Commands;
import mezz.jei.util.MouseHelper;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiRepair;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.gui.inventory.GuiContainerCreative;
import net.minecraft.item.ItemStack;
import org.lwjgl.input.Keyboard;
import org.lwjgl.input.Mouse;

public class InputHandler {

Expand All @@ -35,7 +32,7 @@ public class InputHandler {
@Nonnull
private final ItemListOverlay itemListOverlay;
@Nonnull
private final MouseHelper mouseHelper;
private MouseHelper mouseHelper;
@Nonnull
private final List<IShowsRecipeFocuses> showsRecipeFocuses = new ArrayList<>();

Expand All @@ -52,6 +49,10 @@ public InputHandler(@Nonnull RecipesGui recipesGui, @Nonnull ItemListOverlay ite
showsRecipeFocuses.add(new GuiContainerWrapper());
}

public void onScreenResized() {
this.mouseHelper = new MouseHelper();
}

public boolean handleMouseEvent(@Nonnull GuiScreen guiScreen, int mouseX, int mouseY) {
boolean cancelEvent = false;
if (Mouse.getEventButton() > -1) {
Expand Down

0 comments on commit a4ff37b

Please sign in to comment.