1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-09-28 15:08:47 +00:00

Forward tab key directly to the terminal

Fixes #256
This commit is contained in:
SquidDev 2019-06-21 20:31:28 +01:00
parent 5af789ae11
commit 8fe2abe0ae
2 changed files with 26 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import org.lwjgl.glfw.GLFW;
public final class GuiComputer<T extends ContainerComputerBase> extends ContainerScreen<T> public final class GuiComputer<T extends ContainerComputerBase> extends ContainerScreen<T>
{ {
@ -109,6 +110,18 @@ public final class GuiComputer<T extends ContainerComputerBase> extends Containe
terminal.update(); terminal.update();
} }
@Override
public boolean keyPressed( int key, int scancode, int modifiers )
{
// Forward the tab key to the terminal, rather than moving between controls.
if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper )
{
return getFocused().keyPressed( key, scancode, modifiers );
}
return super.keyPressed( key, scancode, modifiers );
}
@Override @Override
public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY ) public void drawGuiContainerBackgroundLayer( float partialTicks, int mouseX, int mouseY )
{ {

View File

@ -17,6 +17,7 @@ import net.minecraft.client.gui.screen.inventory.ContainerScreen;
import net.minecraft.entity.player.PlayerInventory; import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraft.util.text.ITextComponent; import net.minecraft.util.text.ITextComponent;
import org.lwjgl.glfw.GLFW;
public class GuiTurtle extends ContainerScreen<ContainerTurtle> public class GuiTurtle extends ContainerScreen<ContainerTurtle>
{ {
@ -80,6 +81,18 @@ public class GuiTurtle extends ContainerScreen<ContainerTurtle>
terminal.update(); terminal.update();
} }
@Override
public boolean keyPressed( int key, int scancode, int modifiers )
{
// Forward the tab key to the terminal, rather than moving between controls.
if( key == GLFW.GLFW_KEY_TAB && getFocused() != null && getFocused() == terminalWrapper )
{
return getFocused().keyPressed( key, scancode, modifiers );
}
return super.keyPressed( key, scancode, modifiers );
}
private void drawSelectionSlot( boolean advanced ) private void drawSelectionSlot( boolean advanced )
{ {
// Draw selection slot // Draw selection slot