JPro-one / JPro-Tickets

The right place to report about bugs or suggest improvements for JPro.
https://www.jpro.one
9 stars 4 forks source link

Issue with Copy Functionality on Windows System #175

Open leewyatt opened 4 months ago

leewyatt commented 4 months ago

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();
besidev commented 4 months ago

Hello @leewyatt.

Thank you for bringing this to our attention. We acknowledge the issue with the copy functionality on Windows 11 and were able to replicate it. We will update you as soon as we have made progress on resolving this issue.

leewyatt commented 4 months ago

@besidev Thank you very much~