Platform sync fixes

This commit is contained in:
crschnick
2024-05-04 21:28:37 +00:00
parent 8051412e9f
commit ab13f17fe7
2 changed files with 12 additions and 8 deletions

View File

@@ -4,6 +4,7 @@ import io.xpipe.app.fxcomps.Comp;
import io.xpipe.app.fxcomps.CompStructure;
import io.xpipe.app.fxcomps.SimpleCompStructure;
import io.xpipe.app.fxcomps.util.PlatformThread;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.value.ObservableValue;
@@ -46,7 +47,7 @@ public class ButtonComp extends Comp<CompStructure<Button>> {
public CompStructure<Button> createBase() {
var button = new Button(null);
if (name != null) {
button.textProperty().bind(name);
button.textProperty().bind(PlatformThread.sync(name));
}
var graphic = getGraphic();
if (graphic instanceof FontIcon f) {

View File

@@ -5,6 +5,7 @@ import io.xpipe.app.fxcomps.augment.Augment;
import io.xpipe.app.fxcomps.augment.GrowAugment;
import io.xpipe.app.fxcomps.impl.TooltipAugment;
import io.xpipe.app.fxcomps.util.BindingsHelper;
import io.xpipe.app.fxcomps.util.PlatformThread;
import io.xpipe.app.fxcomps.util.Shortcuts;
import javafx.application.Platform;
@@ -148,13 +149,15 @@ public abstract class Comp<S extends CompStructure<?>> {
var region = struc.get();
BindingsHelper.preserve(region, o);
o.subscribe(n -> {
if (!n) {
region.setVisible(true);
region.setManaged(true);
} else {
region.setVisible(false);
region.setManaged(false);
}
PlatformThread.runLaterIfNeeded(() -> {
if (!n) {
region.setVisible(true);
region.setManaged(true);
} else {
region.setVisible(false);
region.setManaged(false);
}
});
});
});
}