mirror of
https://github.com/darksaid98/draggable_lists.git
synced 2026-12-03 22:16:14 +00:00
Allow double clicking on the server list to join the selected server
Fixes #38
This commit is contained in:
2 files changed
+15
-1
No files matched your search
@@ -21,7 +21,7 @@ public class DragManager<T, E extends ObjectSelectionList.Entry<?>> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
if (button != 0 || selectedItem != null || !isCapMouseY((int) mouseY)) return false;
|
if (selectedItem != null || !isCapMouseY((int) mouseY)) return false;
|
||||||
|
|
||||||
selectedItem = dragList.draggable_lists$getEntryAtPosition(mouseX, mouseY);
|
selectedItem = dragList.draggable_lists$getEntryAtPosition(mouseX, mouseY);
|
||||||
if (selectedItem == null) return false;
|
if (selectedItem == null) return false;
|
||||||
|
|||||||
+14
@@ -6,6 +6,7 @@ import com.mrmelon54.DraggableLists.DragManager;
|
|||||||
import com.mrmelon54.DraggableLists.duck.ServerListDuckProvider;
|
import com.mrmelon54.DraggableLists.duck.ServerListDuckProvider;
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
|
import net.minecraft.Util;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
import net.minecraft.client.gui.components.ObjectSelectionList;
|
import net.minecraft.client.gui.components.ObjectSelectionList;
|
||||||
@@ -26,6 +27,9 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
|||||||
@Final
|
@Final
|
||||||
private JoinMultiplayerScreen screen;
|
private JoinMultiplayerScreen screen;
|
||||||
|
|
||||||
|
@Unique
|
||||||
|
long lastClickTime;
|
||||||
|
|
||||||
@Shadow
|
@Shadow
|
||||||
public abstract void setSelected(@Nullable ServerSelectionList.Entry entry);
|
public abstract void setSelected(@Nullable ServerSelectionList.Entry entry);
|
||||||
|
|
||||||
@@ -49,6 +53,16 @@ public abstract class ServerSelectionListMixin extends ObjectSelectionList<Serve
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
public boolean mouseClicked(double mouseX, double mouseY, int button) {
|
||||||
|
// Double clicks should join the server instead of dragging
|
||||||
|
if (Util.getMillis() - this.lastClickTime < 250L) {
|
||||||
|
draggable_lists$dragManager.mouseReleased(mouseX, mouseY, button);
|
||||||
|
setSelected(getEntryAtPosition(mouseX, mouseY));
|
||||||
|
this.screen.joinSelectedServer();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lastClickTime = Util.getMillis();
|
||||||
|
|
||||||
if (draggable_lists$dragManager.mouseClicked(mouseX, mouseY, button)) return true;
|
if (draggable_lists$dragManager.mouseClicked(mouseX, mouseY, button)) return true;
|
||||||
return super.mouseClicked(mouseX, mouseY, button);
|
return super.mouseClicked(mouseX, mouseY, button);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user