Skip to content

Commit

Permalink
Use page up and page down to scroll pages (#804) Close #200
Browse files Browse the repository at this point in the history
  • Loading branch information
way2muchnoise authored and mezz committed Apr 10, 2017
1 parent e5b303e commit 3dd91ee
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
4 changes: 4 additions & 0 deletions src/main/java/mezz/jei/config/KeyBindings.java
Expand Up @@ -15,6 +15,8 @@ public final class KeyBindings {
public static final KeyBinding showUses = new KeyBinding("key.jei.showUses", KeyConflictContext.GUI, Keyboard.KEY_U, categoryName);
public static final KeyBinding recipeBack = new KeyBinding("key.jei.recipeBack", KeyConflictContext.GUI, Keyboard.KEY_BACK, categoryName);
public static final KeyBinding toggleCheatMode = new KeyBinding("key.jei.toggleCheatMode", KeyConflictContext.GUI, Keyboard.KEY_NONE, categoryName);
public static final KeyBinding previousPage = new KeyBinding("key.jei.previousPage", KeyConflictContext.GUI, Keyboard.KEY_PRIOR, categoryName);
public static final KeyBinding nextPage = new KeyBinding("key.jei.nextPage", KeyConflictContext.GUI, Keyboard.KEY_NEXT, categoryName);

private KeyBindings() {
}
Expand All @@ -26,5 +28,7 @@ public static void init() {
ClientRegistry.registerKeyBinding(showUses);
ClientRegistry.registerKeyBinding(recipeBack);
ClientRegistry.registerKeyBinding(toggleCheatMode);
ClientRegistry.registerKeyBinding(previousPage);
ClientRegistry.registerKeyBinding(nextPage);
}
}
23 changes: 14 additions & 9 deletions src/main/java/mezz/jei/gui/overlay/ItemListOverlay.java
Expand Up @@ -11,6 +11,7 @@
import mezz.jei.api.IItemListOverlay;
import mezz.jei.api.ingredients.IIngredientRegistry;
import mezz.jei.config.Config;
import mezz.jei.config.KeyBindings;
import mezz.jei.config.SessionData;
import mezz.jei.gui.PageNavigation;
import mezz.jei.ingredients.IngredientFilter;
Expand Down Expand Up @@ -276,16 +277,20 @@ public void setKeyboardFocus(boolean keyboardFocus) {
}

public boolean onKeyPressed(char typedChar, int keyCode) {
if (hasKeyboardFocus()) {
boolean handled = searchField.textboxKeyTyped(typedChar, keyCode);
if (handled) {
boolean changed = Config.setFilterText(searchField.getText());
if (changed) {
SessionData.setFirstItemIndex(0);
updateLayout();
}
if (hasKeyboardFocus() &&
searchField.textboxKeyTyped(typedChar, keyCode)) {
boolean changed = Config.setFilterText(searchField.getText());
if (changed) {
SessionData.setFirstItemIndex(0);
updateLayout();
}
return handled;
return true;
} else if (KeyBindings.nextPage.isActiveAndMatches(keyCode)) {
nextPage();
return true;
} else if (KeyBindings.previousPage.isActiveAndMatches(keyCode)) {
previousPage();
return true;
}
return false;
}
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/mezz/jei/gui/recipes/RecipesGui.java
Expand Up @@ -24,6 +24,7 @@
import mezz.jei.input.IClickedIngredient;
import mezz.jei.input.IShowsRecipeFocuses;
import mezz.jei.input.InputHandler;
import mezz.jei.input.MouseHelper;
import mezz.jei.transfer.RecipeTransferUtil;
import mezz.jei.util.ErrorUtil;
import mezz.jei.util.Translator;
Expand Down Expand Up @@ -312,8 +313,18 @@ protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOEx
protected void keyTyped(char typedChar, int keyCode) throws IOException {
if (InputHandler.isInventoryCloseKey(keyCode) || InputHandler.isInventoryToggleKey(keyCode)) {
close();
keyHandled = true;
} else if (KeyBindings.recipeBack.isActiveAndMatches(keyCode)) {
back();
keyHandled = true;
} else if (!Internal.getRuntime().getItemListOverlay().isMouseOver(MouseHelper.getX(), MouseHelper.getY())) {
if (KeyBindings.nextPage.isActiveAndMatches(keyCode)) {
logic.nextPage();
keyHandled = true;
} else if (KeyBindings.previousPage.isActiveAndMatches(keyCode)) {
logic.previousPage();
keyHandled = true;
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/assets/jei/lang/en_us.lang
Expand Up @@ -29,8 +29,10 @@ key.jei.toggleOverlay=Toggle Item List Overlay
key.jei.focusSearch=Select Search Bar
key.jei.showRecipe=Show Item Recipe
key.jei.showUses=Show Item Uses
key.jei.recipeBack=Show Previous Recipe Page
key.jei.recipeBack=Show Previously Viewed Recipe
key.jei.toggleCheatMode=Toggle Item Cheating Mode
key.jei.previousPage=Show Next Page
key.jei.nextPage=Show Previous Page

# Config
config.jei.default=Default
Expand Down

0 comments on commit 3dd91ee

Please sign in to comment.