|
16 | 16 | import java.util.function.IntSupplier; |
17 | 17 | import java.util.function.IntUnaryOperator; |
18 | 18 |
|
| 19 | +import javafx.application.Platform; |
19 | 20 | import javafx.beans.NamedArg; |
20 | 21 | import javafx.beans.binding.Bindings; |
21 | 22 | import javafx.beans.property.BooleanProperty; |
|
53 | 54 | import javafx.scene.shape.PathElement; |
54 | 55 | import javafx.scene.text.TextFlow; |
55 | 56 |
|
56 | | -import javafx.application.Platform; |
57 | 57 | import org.fxmisc.flowless.Cell; |
58 | 58 | import org.fxmisc.flowless.VirtualFlow; |
59 | 59 | import org.fxmisc.flowless.VirtualFlowHit; |
@@ -802,21 +802,29 @@ public GenericStyledArea( |
802 | 802 | () -> getLength() == 0 && ! isFocused(), |
803 | 803 | lengthProperty(), focusedProperty() |
804 | 804 | ); |
805 | | - |
806 | | - placeHolderProp.addListener( (ob,oldNode,newNode) -> { |
807 | | - if ( oldNode != null ) { |
808 | | - oldNode.visibleProperty().unbind(); |
809 | | - oldNode.layoutXProperty().unbind(); |
810 | | - oldNode.layoutYProperty().unbind(); |
811 | | - getChildren().remove( oldNode ); |
812 | | - setClip( null ); |
813 | | - } |
814 | | - if ( newNode != null ) { |
815 | | - newNode.visibleProperty().bind( showPlaceholder ); |
816 | | - configurePlaceholder( newNode ); |
817 | | - getChildren().add( newNode ); |
818 | | - } |
819 | | - }); |
| 805 | + |
| 806 | + placeHolderProp.addListener( (ob,ov,newNode) -> displayPlaceHolder( showPlaceholder.getValue(), newNode ) ); |
| 807 | + showPlaceholder.addListener( (ob,ov,show) -> displayPlaceHolder( show, getPlaceholder() ) ); |
| 808 | + } |
| 809 | + |
| 810 | + private Node placeholder; |
| 811 | + |
| 812 | + private void displayPlaceHolder( boolean show, Node newNode ) |
| 813 | + { |
| 814 | + if ( placeholder != null && (! show || newNode != placeholder) ) |
| 815 | + { |
| 816 | + placeholder.layoutXProperty().unbind(); |
| 817 | + placeholder.layoutYProperty().unbind(); |
| 818 | + getChildren().remove( placeholder ); |
| 819 | + placeholder = null; |
| 820 | + setClip( null ); |
| 821 | + } |
| 822 | + if ( newNode != null && show && newNode != placeholder ) |
| 823 | + { |
| 824 | + configurePlaceholder( newNode ); |
| 825 | + getChildren().add( newNode ); |
| 826 | + placeholder = newNode; |
| 827 | + } |
820 | 828 | } |
821 | 829 |
|
822 | 830 | protected void configurePlaceholder( Node placeholder ) |
@@ -1442,9 +1450,9 @@ protected void layoutChildren() { |
1442 | 1450 | paging = false; |
1443 | 1451 | }); |
1444 | 1452 |
|
1445 | | - Node node = getPlaceholder(); |
1446 | | - if (node != null && node.isResizable() && node.isManaged()) { |
1447 | | - node.autosize(); |
| 1453 | + Node holder = placeholder; |
| 1454 | + if (holder != null && holder.isResizable() && holder.isManaged()) { |
| 1455 | + holder.autosize(); |
1448 | 1456 | } |
1449 | 1457 | } |
1450 | 1458 |
|
|
0 commit comments