|
24 | 24 | import javafx.scene.layout.Pane; |
25 | 25 | import javafx.scene.text.TextFlow; |
26 | 26 |
|
| 27 | +/** |
| 28 | + * A text field whose segment generic has been specified to be a {@link String}. How the text |
| 29 | + * will be styled is not yet specified in this class, but use {@link StyleClassedTextField} for a style class |
| 30 | + * approach to styling the text and {@link InlineCssTextField} for an inline css approach to styling the text. |
| 31 | + * |
| 32 | + * @param <PS> type of paragraph style |
| 33 | + * @param <S> type of style that can be applied to text. |
| 34 | + * |
| 35 | + * @author Jurgen |
| 36 | + */ |
27 | 37 | public class StyledTextField<PS, S> extends StyledTextArea |
28 | 38 | { |
29 | 39 | private final Pattern VERTICAL_WHITESPACE = Pattern.compile( "\\v+" ); |
@@ -82,6 +92,14 @@ else if ( ! focused && was ) { |
82 | 92 | } |
83 | 93 | selectAll = true; |
84 | 94 | }); |
| 95 | + |
| 96 | + super.setWrapText( false ); |
| 97 | + wrapTextProperty().addListener( (ob,ov,wrap) -> { |
| 98 | + if ( wrap ) { // veto any changes |
| 99 | + wrapTextProperty().unbind(); |
| 100 | + super.setWrapText(false); |
| 101 | + } |
| 102 | + }); |
85 | 103 | } |
86 | 104 |
|
87 | 105 | /* |
@@ -155,4 +173,9 @@ public void replaceText( int start, int end, String text ) |
155 | 173 | { |
156 | 174 | super.replaceText( start, end, VERTICAL_WHITESPACE.matcher( text ).replaceAll( " " ) ); |
157 | 175 | } |
| 176 | + |
| 177 | + /** This is a <b>no op</b> for text fields and therefore marked as <i>deprecated</i>. */ |
| 178 | + @Override @Deprecated public void setWrapText( boolean value ) {} |
| 179 | + /** This <u>always</u> returns <b>false</b> for styled text fields. */ |
| 180 | + @Override public boolean isWrapText() { return false; } |
158 | 181 | } |
0 commit comments