Fix password field styling

This commit is contained in:
crschnick 2023-06-06 18:02:21 +00:00
parent b997e7674d
commit a056cf95a2
2 changed files with 3 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import io.xpipe.beacon.exchange.AskpassExchange;
import io.xpipe.core.util.SecretValue;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.Alert;
import javafx.scene.layout.StackPane;
import java.util.HashMap;
import java.util.Map;
@ -47,8 +48,7 @@ public class AskpassExchangeImpl extends AskpassExchange
alert.setAlertType(Alert.AlertType.CONFIRMATION);
var text = new SecretFieldComp(prop).createRegion();
text.setStyle("-fx-border-width: 1px");
alert.getDialogPane().setContent(text);
alert.getDialogPane().setContent(new StackPane(text));
})
.filter(b -> b.getButtonData().isDefaultButton() && prop.getValue() != null)
.map(t -> {

View file

@ -25,6 +25,7 @@ public class SecretFieldComp extends Comp<CompStructure<TextField>> {
@Override
public CompStructure<TextField> createBase() {
var text = new PasswordField();
text.getStyleClass().add("secret-field-comp");
text.setText(value.getValue() != null ? value.getValue().getSecretValue() : null);
text.textProperty().addListener((c, o, n) -> {
value.setValue(n != null && n.length() > 0 ? encrypt(n.toCharArray()) : null);