Skip to content

Commit

Permalink
Add double-click
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Jul 22, 2024
1 parent 37bfdcc commit c174383
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import io.github.gaming32.worldhost.plugin.InfoTextsCategory;
import io.github.gaming32.worldhost.plugin.ProfileInfo;
import io.github.gaming32.worldhost.versions.Components;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ObjectSelectionList;
Expand Down Expand Up @@ -170,6 +171,8 @@ public class FriendsEntry extends ObjectSelectionList.Entry<FriendsEntry> {
private final FriendListFriend friend;
private ProfileInfo profile;

private long clickTime;

public FriendsEntry(FriendListFriend friend) {
minecraft = Minecraft.getInstance();
this.friend = friend;
Expand Down Expand Up @@ -225,6 +228,12 @@ public void maybeRemove() {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
FriendsScreen.this.list.setSelected(this);
if (Util.getMillis() - clickTime < 250L) {
friend.showFriendInfo(FriendsScreen.this);
clickTime = Util.getMillis();
return true;
}
clickTime = Util.getMillis();
return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
final double relX = mouseX - OnlineFriendsScreen.this.list.getRowLeft();
if (relX < 32.0 && relX > 16.0) {
connect();
clickTime = Util.getMillis();
return true;
}

Expand Down

0 comments on commit c174383

Please sign in to comment.