mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-03 12:49:11 +00:00
Fix mouse_drag not firing for right/middle buttons
This is a bit of an odd combination of a few bugs: - When the terminal component is blurred, we fire a mouse_up event for the last-held button. However, we had an off-by-1 error here, so this only triggered for the right/middle buttons. - This was obsucuring the second bug, which is when we clicked within the terminal, this caused the terminal to be blurred (thus releasing the mouse) and then focused again. We fix this by only setting the focus if there's actually a change. Fixes #1655
This commit is contained in:
parent
1f7d245876
commit
488f66eead
@ -19,6 +19,7 @@ import dan200.computercraft.shared.network.server.UploadFileMessage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.Util;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.entity.player.Inventory;
|
||||
@ -144,6 +145,11 @@ public abstract class AbstractComputerScreen<T extends AbstractComputerMenu> ext
|
||||
|| super.mouseDragged(x, y, button, deltaX, deltaY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFocused(@Nullable GuiEventListener listener) {
|
||||
// Don't clear and re-focus if we're already focused.
|
||||
if (listener != getFocused()) super.setFocused(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void renderLabels(GuiGraphics graphics, int mouseX, int mouseY) {
|
||||
|
@ -246,7 +246,7 @@ public class TerminalWidget extends AbstractWidget {
|
||||
keysDown.clear();
|
||||
|
||||
// When blurring, we should make the last mouse button go up
|
||||
if (lastMouseButton > 0) {
|
||||
if (lastMouseButton >= 0) {
|
||||
computer.mouseUp(lastMouseButton + 1, lastMouseX + 1, lastMouseY + 1);
|
||||
lastMouseButton = -1;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user