Skip to content

Commit

Permalink
Added TextArea wrapText property support
Browse files Browse the repository at this point in the history
  • Loading branch information
salmonb committed Jun 16, 2024
1 parent 7460043 commit fa395f7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package javafx.scene.control;

import dev.webfx.kit.registry.javafxcontrols.JavaFxControlsRegistry;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;

/**
* @author Bruno Salmon
Expand All @@ -26,6 +28,13 @@ public TextArea(String text) {
setText(text);
}

private final BooleanProperty wrapTextProperty = new SimpleBooleanProperty(false);

public final BooleanProperty wrapTextProperty() { return wrapTextProperty; }
public final boolean isWrapText() { return wrapTextProperty.getValue(); }
public final void setWrapText(boolean value) { wrapTextProperty.setValue(value); }


static {
JavaFxControlsRegistry.registerTextArea();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package dev.webfx.kit.mapper.peers.javafxcontrols.base;

import dev.webfx.kit.mapper.peers.javafxgraphics.SceneRequester;
import javafx.beans.value.ObservableValue;
import javafx.scene.control.TextArea;

/**
Expand All @@ -10,4 +12,20 @@ public class TextAreaPeerBase

extends TextInputControlPeerBase<N, NB, NM> {

@Override
public void bind(N buttonBase, SceneRequester sceneRequester) {
super.bind(buttonBase, sceneRequester);
requestUpdateOnPropertiesChange(sceneRequester
, node.wrapTextProperty()
);
}

@Override
public boolean updateProperty(ObservableValue changedProperty) {
return super.updateProperty(changedProperty)
|| updateProperty(node.wrapTextProperty(), changedProperty, mixin::updateWrapText)
;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ public interface TextAreaPeerMixin
<N extends TextArea, NB extends TextAreaPeerBase<N, NB, NM>, NM extends TextAreaPeerMixin<N, NB, NM>>

extends TextInputControlPeerMixin<N, NB, NM> {

void updateWrapText(boolean wrapText);
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@ public HtmlTextAreaPeer() {
getElement().style.resize = "none"; // To disable the html text area resize feature
}

@Override
public void updateWrapText(boolean wrapText) {
setElementStyleAttribute("word-break", wrapText ? "break-word" : "normal");
}
}

0 comments on commit fa395f7

Please sign in to comment.