1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2024-07-01 01:23:30 +00:00

Prevent terminal buttons stealing focus

I have shutdown my computer by accident far too many times now.
This commit is contained in:
Jonathan Coates 2021-12-08 23:16:53 +00:00
parent 47ad7a35dc
commit 0e4b7a5a75
No known key found for this signature in database
GPG Key ID: B9E431FF07C98D06

View File

@ -8,6 +8,7 @@
import com.mojang.blaze3d.matrix.MatrixStack;
import dan200.computercraft.ComputerCraft;
import dan200.computercraft.client.gui.widgets.ComputerSidebar;
import dan200.computercraft.client.gui.widgets.DynamicImageButton;
import dan200.computercraft.client.gui.widgets.WidgetTerminal;
import dan200.computercraft.shared.computer.core.ClientComputer;
import dan200.computercraft.shared.computer.core.ComputerFamily;
@ -102,6 +103,16 @@ public final void render( @Nonnull MatrixStack stack, int mouseX, int mouseY, fl
renderTooltip( stack, mouseX, mouseY );
}
@Override
public boolean mouseClicked( double x, double y, int button )
{
boolean changed = super.mouseClicked( x, y, button );
// Clicking the terminate/shutdown button steals focus, which means then pressing "enter" will click the button
// again. Restore the focus to the terminal in these cases.
if( getFocused() instanceof DynamicImageButton ) setFocused( terminal );
return changed;
}
@Override
public final boolean mouseDragged( double x, double y, int button, double deltaX, double deltaY )
{