Skip to content

Issue with Copy Functionality on Windows System #175

Description

@leewyatt

Description:
We have encountered an issue with the copy functionality specifically on the Windows operating system. Despite successful implementation and functionality on macOS, the copy feature fails to work as expected on Windows.

We have added a right-click copy menu to a Label component in our application. While this functionality works well on macOS, allowing users to copy the entire content, it fails to achieve the same on Windows.

Platform: Windows 11
JavaFX: 22.0.1
JAVA: 21
jpro-routing-core: 0.2.10
jpro-webapi:2023.3.3
Environment: Local javafx client, not running in a web browser.

Below is the code snippet used for adding the copy menu to the Label:

    Label testLabel = new Label("Id: 12345");
        testLabel.setOnContextMenuRequested(evt -> {
            ContextMenu contextMenu = testLabel.getContextMenu();
            if (contextMenu == null) {
                MenuItem copyItem = new MenuItem("Copy");
                contextMenu = new ContextMenu(copyItem);
                contextMenu.setOnShown(event -> {
                    Node node = copyItem.getStyleableNode();
                    if (node != null) {
                        CopyUtil.setCopyOnClick(node, "12345");
                    }
                });
                testLabel. setContextMenu(contextMenu);
            }
            contextMenu.show(testLabel, evt.getScreenX(), evt.getScreenY());
        });

Other demo

                Dialog<Void> dialog = new Dialog<>();
                    dialog.setTitle("Test");
                    Button copyButton = new Button("Copy Button");
                    dialog.getDialogPane().setContent(copyButton);
                    CopyUtil.setCopyOnClick(copyButton, "Copy Button Content"); // Works well

                    dialog.getDialogPane().getButtonTypes().addAll(ButtonType.APPLY, ButtonType.CANCEL);

                    Node node = dialog.getDialogPane().lookupButton(ButtonType.APPLY);
                    CopyUtil.setCopyOnClick(node, "Copy Apply Button Content"); // not working !~

                    dialog.show();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions