Reputation: 165
I have a problem in javafx text area: When I focus the text area, border is applied... that is ok.
But when I drag with scroll-bar handle, the text area border focus is lost.
See the image below:
This is the my simple text area:
Text area changed when focused like this:
But when I scroll in text area with the scroll handle, the border is changed like before (un-focused) state:
Is there any way to control text area within scroll pane (in text area)?
Upvotes: 1
Views: 323
Reputation: 9959
One possible work around is to not allow focus on the ScrollPane within TextArea. ie., the moment ScrollPane gets focus we force to focus on TextArea. This way the focus will be always on TextArea.
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextArea;
public class CustomTextArea extends TextArea {
private ScrollPane textAreaScrollPane;
@Override
protected void layoutChildren() {
super.layoutChildren();
if (textAreaScrollPane == null) {
textAreaScrollPane = (ScrollPane) lookup(".scroll-pane");
textAreaScrollPane.focusedProperty().addListener((obs, oldVal, focused) -> {
if (focused) {
requestFocus();
}
});
}
}
}
And you will use this CustomTextArea across your application.
TextArea textArea = new CustomTextArea();
Upvotes: 0