From e6cbf48ed8532ef3c2daf6a80ba41bba045d7b2a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emmanuel=20Beno=C3=AEt?= Date: Thu, 21 Jul 2016 11:19:30 +0200 Subject: [PATCH] Keyboard shortcuts in recipe selectors (alloy furnace & workbench) --- TODO.txt | 1 - .../mmm/tech/base/alloy_furnace/TBAFGui.java | 21 ++++++++++++++++++- src/java/mmm/tech/base/workbench/TBWBGui.java | 17 ++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/TODO.txt b/TODO.txt index 0053573..327fbcf 100644 --- a/TODO.txt +++ b/TODO.txt @@ -47,7 +47,6 @@ tech.base No Metal recycler / advanced furnace tech.base No Workbench Support for remaining recipe types BF Allow clicking ingredients to get their recipe BF - Keyboard shortcuts BF ------------------------------------------------------------------------------------------------------- tech.tools No Pan (for e.g. panning gold) -> limit it per chunk diff --git a/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java b/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java index 1616c72..4e5b2b5 100644 --- a/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java +++ b/src/java/mmm/tech/base/alloy_furnace/TBAFGui.java @@ -3,6 +3,8 @@ package mmm.tech.base.alloy_furnace; import java.util.ArrayList; +import org.lwjgl.input.Keyboard; + import mmm.Mmm; import mmm.core.CNetwork; import mmm.materials.MAlloyRecipe; @@ -159,10 +161,27 @@ public class TBAFGui @Override public boolean onKeyTyped( final char typedChar , final int keyCode ) { - if ( this.tfSearch.textboxKeyTyped( typedChar , keyCode ) ) { + if ( this.tfSearch.isFocused( ) && keyCode == Keyboard.KEY_ESCAPE ) { + this.tfSearch.setFocused( false ); + return true; + + } else if ( this.tfSearch.textboxKeyTyped( typedChar , keyCode ) ) { ( (TBAFGui) this.parent ).handleFiltering( this.tfSearch.getText( ) ); return true; + + } else if ( typedChar == 't' || typedChar == 'T' ) { + this.tfSearch.setFocused( true ); + return true; + + } else if ( keyCode == Keyboard.KEY_LEFT && this.bPrevious.enabled ) { + this.onActionPerformed( this.bPrevious ); + return true; + + } else if ( keyCode == Keyboard.KEY_RIGHT && this.bNext.enabled ) { + this.onActionPerformed( this.bNext ); + return true; } + return false; } diff --git a/src/java/mmm/tech/base/workbench/TBWBGui.java b/src/java/mmm/tech/base/workbench/TBWBGui.java index 3f64edd..ccd94b2 100644 --- a/src/java/mmm/tech/base/workbench/TBWBGui.java +++ b/src/java/mmm/tech/base/workbench/TBWBGui.java @@ -5,6 +5,8 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import org.lwjgl.input.Keyboard; + import mmm.Mmm; import mmm.core.CNetwork; import mmm.core.api.recipes.I_CraftingRecipeWrapper; @@ -125,8 +127,21 @@ public class TBWBGui protected void keyTyped( final char typedChar , final int keyCode ) throws IOException { - if ( this.tfSearch.textboxKeyTyped( typedChar , keyCode ) ) { + if ( this.tfSearch.isFocused( ) && keyCode == Keyboard.KEY_ESCAPE ) { + this.tfSearch.setFocused( false ); + + } else if ( this.tfSearch.textboxKeyTyped( typedChar , keyCode ) ) { this.handleFiltering( this.tfSearch.getText( ) ); + + } else if ( typedChar == 't' || typedChar == 'T' ) { + this.tfSearch.setFocused( true ); + + } else if ( keyCode == Keyboard.KEY_LEFT && this.bPrevious.enabled ) { + this.actionPerformed( this.bPrevious ); + + } else if ( keyCode == Keyboard.KEY_RIGHT && this.bNext.enabled ) { + this.actionPerformed( this.bNext ); + } else { super.keyTyped( typedChar , keyCode ); }