* Close #3664: 支持双击复制世界信息 * update * update
This commit is contained in:
@@ -1105,6 +1105,18 @@ public final class FXUtils {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void copyOnDoubleClick(Labeled label) {
|
||||||
|
label.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> {
|
||||||
|
if (e.getButton() == MouseButton.PRIMARY && e.getClickCount() == 2) {
|
||||||
|
String text = label.getText();
|
||||||
|
if (text != null && !text.isEmpty()) {
|
||||||
|
copyText(label.getText());
|
||||||
|
e.consume();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static void copyText(String text) {
|
public static void copyText(String text) {
|
||||||
ClipboardContent content = new ClipboardContent();
|
ClipboardContent content = new ClipboardContent();
|
||||||
content.putString(text);
|
content.putString(text);
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
BorderPane.setAlignment(label, Pos.CENTER_LEFT);
|
||||||
|
|
||||||
Label worldNameLabel = new Label();
|
Label worldNameLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(worldNameLabel);
|
||||||
worldNameLabel.setText(world.getWorldName());
|
worldNameLabel.setText(world.getWorldName());
|
||||||
BorderPane.setAlignment(worldNameLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(worldNameLabel, Pos.CENTER_RIGHT);
|
||||||
worldNamePane.setRight(worldNameLabel);
|
worldNamePane.setRight(worldNameLabel);
|
||||||
@@ -115,6 +116,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
gameVersionPane.setLeft(label);
|
gameVersionPane.setLeft(label);
|
||||||
|
|
||||||
Label gameVersionLabel = new Label();
|
Label gameVersionLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(gameVersionLabel);
|
||||||
gameVersionLabel.setText(world.getGameVersion());
|
gameVersionLabel.setText(world.getGameVersion());
|
||||||
BorderPane.setAlignment(gameVersionLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(gameVersionLabel, Pos.CENTER_RIGHT);
|
||||||
gameVersionPane.setRight(gameVersionLabel);
|
gameVersionPane.setRight(gameVersionLabel);
|
||||||
@@ -127,6 +129,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
randomSeedPane.setLeft(label);
|
randomSeedPane.setLeft(label);
|
||||||
|
|
||||||
Label randomSeedLabel = new Label();
|
Label randomSeedLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(randomSeedLabel);
|
||||||
BorderPane.setAlignment(randomSeedLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(randomSeedLabel, Pos.CENTER_RIGHT);
|
||||||
randomSeedPane.setRight(randomSeedLabel);
|
randomSeedPane.setRight(randomSeedLabel);
|
||||||
|
|
||||||
@@ -143,6 +146,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
lastPlayedPane.setLeft(label);
|
lastPlayedPane.setLeft(label);
|
||||||
|
|
||||||
Label lastPlayedLabel = new Label();
|
Label lastPlayedLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(lastPlayedLabel);
|
||||||
lastPlayedLabel.setText(formatDateTime(Instant.ofEpochMilli(world.getLastPlayed())));
|
lastPlayedLabel.setText(formatDateTime(Instant.ofEpochMilli(world.getLastPlayed())));
|
||||||
BorderPane.setAlignment(lastPlayedLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(lastPlayedLabel, Pos.CENTER_RIGHT);
|
||||||
lastPlayedPane.setRight(lastPlayedLabel);
|
lastPlayedPane.setRight(lastPlayedLabel);
|
||||||
@@ -155,6 +159,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
timePane.setLeft(label);
|
timePane.setLeft(label);
|
||||||
|
|
||||||
Label timeLabel = new Label();
|
Label timeLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(timeLabel);
|
||||||
BorderPane.setAlignment(timeLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(timeLabel, Pos.CENTER_RIGHT);
|
||||||
timePane.setRight(timeLabel);
|
timePane.setRight(timeLabel);
|
||||||
|
|
||||||
@@ -258,6 +263,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
locationPane.setLeft(label);
|
locationPane.setLeft(label);
|
||||||
|
|
||||||
Label locationLabel = new Label();
|
Label locationLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(locationLabel);
|
||||||
BorderPane.setAlignment(locationLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(locationLabel, Pos.CENTER_RIGHT);
|
||||||
locationPane.setRight(locationLabel);
|
locationPane.setRight(locationLabel);
|
||||||
|
|
||||||
@@ -276,6 +282,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
lastDeathLocationPane.setLeft(label);
|
lastDeathLocationPane.setLeft(label);
|
||||||
|
|
||||||
Label lastDeathLocationLabel = new Label();
|
Label lastDeathLocationLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(lastDeathLocationLabel);
|
||||||
BorderPane.setAlignment(lastDeathLocationLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(lastDeathLocationLabel, Pos.CENTER_RIGHT);
|
||||||
lastDeathLocationPane.setRight(lastDeathLocationLabel);
|
lastDeathLocationPane.setRight(lastDeathLocationLabel);
|
||||||
|
|
||||||
@@ -297,6 +304,7 @@ public final class WorldInfoPage extends StackPane implements DecoratorPage {
|
|||||||
spawnPane.setLeft(label);
|
spawnPane.setLeft(label);
|
||||||
|
|
||||||
Label spawnLabel = new Label();
|
Label spawnLabel = new Label();
|
||||||
|
FXUtils.copyOnDoubleClick(spawnLabel);
|
||||||
BorderPane.setAlignment(spawnLabel, Pos.CENTER_RIGHT);
|
BorderPane.setAlignment(spawnLabel, Pos.CENTER_RIGHT);
|
||||||
spawnPane.setRight(spawnLabel);
|
spawnPane.setRight(spawnLabel);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user