mirror of
https://github.com/sparrowwallet/sparrow.git
synced 2024-11-02 20:36:44 +00:00
copy context menu changes on receive tab
This commit is contained in:
parent
1887e1c7b0
commit
f1cddc28e7
4 changed files with 39 additions and 4 deletions
|
@ -10,6 +10,7 @@ import javafx.beans.value.ChangeListener;
|
|||
import javafx.event.EventHandler;
|
||||
import javafx.scene.Cursor;
|
||||
import javafx.scene.Node;
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.Tooltip;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
|
@ -52,6 +53,7 @@ public class CopyableTextField extends CustomTextField {
|
|||
selectedTextProperty().removeListener(selectionListener);
|
||||
}
|
||||
});
|
||||
setContextMenu(new ContextMenu());
|
||||
}
|
||||
|
||||
private void setupCopyButtonField(ObjectProperty<Node> rightProperty) {
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package com.sparrowwallet.sparrow.control;
|
||||
|
||||
import javafx.scene.control.ContextMenu;
|
||||
import javafx.scene.control.MenuItem;
|
||||
import javafx.scene.input.Clipboard;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import org.fxmisc.richtext.CodeArea;
|
||||
|
||||
public class SelectableCodeArea extends CodeArea {
|
||||
public SelectableCodeArea() {
|
||||
super();
|
||||
|
||||
ContextMenu contextMenu = new ContextMenu();
|
||||
MenuItem copy = new MenuItem("Copy");
|
||||
copy.setDisable(true);
|
||||
copy.setOnAction(event -> {
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(getSelectedText());
|
||||
Clipboard.getSystemClipboard().setContent(content);
|
||||
});
|
||||
MenuItem copyAll = new MenuItem("Copy All");
|
||||
copyAll.setOnAction(event -> {
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
content.putString(getText());
|
||||
Clipboard.getSystemClipboard().setContent(content);
|
||||
});
|
||||
contextMenu.getItems().addAll(copy, copyAll);
|
||||
setContextMenu(contextMenu);
|
||||
|
||||
selectedTextProperty().addListener((observable, oldValue, newValue) -> {
|
||||
copy.setDisable(newValue.isEmpty());
|
||||
});
|
||||
}
|
||||
}
|
|
@ -27,7 +27,6 @@ import javafx.scene.control.*;
|
|||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import org.controlsfx.glyphfont.Glyph;
|
||||
import org.fxmisc.richtext.CodeArea;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -63,7 +62,7 @@ public class ReceiveController extends WalletFormController implements Initializ
|
|||
private ScriptArea scriptPubKeyArea;
|
||||
|
||||
@FXML
|
||||
private CodeArea outputDescriptor;
|
||||
private SelectableCodeArea outputDescriptor;
|
||||
|
||||
@FXML
|
||||
private Button displayAddress;
|
||||
|
|
|
@ -12,11 +12,11 @@
|
|||
<?import tornadofx.control.Field?>
|
||||
<?import javafx.scene.image.ImageView?>
|
||||
<?import org.fxmisc.flowless.VirtualizedScrollPane?>
|
||||
<?import org.fxmisc.richtext.CodeArea?>
|
||||
<?import com.sparrowwallet.sparrow.control.CopyableLabel?>
|
||||
<?import org.controlsfx.glyphfont.Glyph?>
|
||||
<?import com.sparrowwallet.sparrow.control.CopyableTextField?>
|
||||
<?import com.sparrowwallet.sparrow.control.ScriptArea?>
|
||||
<?import com.sparrowwallet.sparrow.control.SelectableCodeArea?>
|
||||
|
||||
<BorderPane stylesheets="@receive.css, @wallet.css, @../script.css, @../descriptor.css, @../general.css" styleClass="wallet-pane" xmlns="http://javafx.com/javafx/10.0.2-internal" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.sparrowwallet.sparrow.wallet.ReceiveController">
|
||||
<center>
|
||||
|
@ -72,7 +72,7 @@
|
|||
<Field text="Descriptor:">
|
||||
<VirtualizedScrollPane>
|
||||
<content>
|
||||
<CodeArea fx:id="outputDescriptor" editable="false" wrapText="true" prefHeight="68" maxHeight="68" styleClass="uneditable-codearea" />
|
||||
<SelectableCodeArea fx:id="outputDescriptor" editable="false" wrapText="true" prefHeight="68" maxHeight="68" styleClass="uneditable-codearea" />
|
||||
</content>
|
||||
</VirtualizedScrollPane>
|
||||
</Field>
|
||||
|
|
Loading…
Reference in a new issue