Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text Area's node orientation doesn't reflect on text when updated from an accelerator. #86

Open
Moubassher opened this issue Feb 22, 2025 · 1 comment

Comments

@Moubassher
Copy link

KeyCombination rtlShortcut = new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_ANY);
        Runnable RTLrunnable = () -> {
            Platform.runLater(() -> {
                optionTA.setNodeOrientation(NodeOrientation.RIGHT_TO_LEFT);
            });
            System.out.println("optionTA's node orientation: " + optionTA.getNodeOrientation());
        };

        KeyboardShortcuts.getInstance().addKeyboardShortcut(rtlShortcut,RTLrunnable);

The print statement shows the optionTA's node orientation does change, but the text doesn't reflect so. When I use a choice box that's next to the text area, it does change:

        textDirectionCB.getItems().addAll(NodeOrientation.LEFT_TO_RIGHT, NodeOrientation.RIGHT_TO_LEFT);
        
onOrientationChanged(optionTA::setNodeOrientation);

private void onOrientationChanged(Consumer<NodeOrientation> orientationChangeFunc) {
        textDirectionCB.getSelectionModel().selectedItemProperty()
                .addListener((a, b, selectedOrientation) ->
                        orientationChangeFunc.accept(selectedOrientation));
    }

Whether I make sure the code is run from the UI thread or not by calling Platform.runLater(...), nothing changes.

@Moubassher
Copy link
Author

okay, I realized since the FXML's file/controller class are duplicated on the UI, one got the shortcut and the other's didn't (because the accelerators are a map. As a workaround, I should only activate the shortcut while the text area has focus.
P.S: I would've deleted the issue, but apparently this is not possible on this repo, so marking it as closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant