Search code examples
kotlincopy-pastetornadofx

TornadoFX: Allow copying an item from a listview to clipboard


When an item in a listview is selected, I would like the user to be able to copy the content to the clipboard. How can I achieve that?


Solution

  • You could add a shortcut to the view like so

    shortcut(KeyCombination.valueOf("Ctrl+C")) {
        // Convert the selected item as you see fit and add it to the clipboard
        // For example:
        clipboard.put(MyCustomFormat, listview.selectedItem)
    }