-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copy context menu changes on receive tab
- Loading branch information
Showing
4 changed files
with
39 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/sparrowwallet/sparrow/control/SelectableCodeArea.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters