mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 13:42:59 +00:00 
			
		
		
		
	Prevent terminal buttons stealing focus
I have shutdown my computer by accident far too many times now.
This commit is contained in:
		| @@ -8,6 +8,7 @@ package dan200.computercraft.client.gui; | ||||
| 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 abstract class ComputerScreenBase<T extends ContainerComputerBase> extend | ||||
|         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 ) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Jonathan Coates
					Jonathan Coates