mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 15:40:23 +00:00
Rework choice pane handling for #125
This commit is contained in:
parent
ea882bcc43
commit
8c8dd99ad2
2 changed files with 15 additions and 3 deletions
|
@ -1,6 +1,7 @@
|
|||
package io.xpipe.app.comp.base;
|
||||
|
||||
import atlantafx.base.controls.Spacer;
|
||||
import atlantafx.base.theme.Styles;
|
||||
import com.jfoenix.controls.JFXTabPane;
|
||||
import io.xpipe.app.core.AppI18n;
|
||||
import io.xpipe.app.fxcomps.Comp;
|
||||
|
@ -200,7 +201,7 @@ public abstract class MultiStepComp extends Comp<CompStructure<VBox>> {
|
|||
var nextText = Bindings.createStringBinding(
|
||||
() -> isLastPage() ? AppI18n.get("finishStep") : AppI18n.get("nextStep"), currentStep);
|
||||
var nextButton = new ButtonComp(nextText, null, comp::next)
|
||||
.apply(struc -> struc.get().setDefaultButton(true))
|
||||
.styleClass(Styles.ACCENT)
|
||||
.styleClass("next");
|
||||
|
||||
var previousButton = new ButtonComp(AppI18n.observable("previousStep"), null, comp::previous)
|
||||
|
|
|
@ -9,6 +9,7 @@ import javafx.beans.property.Property;
|
|||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.collections.FXCollections;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.layout.Region;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.util.StringConverter;
|
||||
|
@ -29,8 +30,14 @@ public class ChoicePaneComp extends Comp<CompStructure<VBox>> {
|
|||
|
||||
@Override
|
||||
public CompStructure<VBox> createBase() {
|
||||
var list = FXCollections.observableArrayList(entries);
|
||||
var list = FXCollections.observableArrayList(entries);
|
||||
var cb = new ComboBox<>(list);
|
||||
cb.setOnKeyPressed(event -> {
|
||||
if (!cb.isShowing() && event.getCode().equals(KeyCode.ENTER)) {
|
||||
cb.show();
|
||||
event.consume();
|
||||
}
|
||||
});
|
||||
cb.getSelectionModel().select(selected.getValue());
|
||||
cb.setConverter(new StringConverter<>() {
|
||||
@Override
|
||||
|
@ -63,8 +70,12 @@ public class ChoicePaneComp extends Comp<CompStructure<VBox>> {
|
|||
} else {
|
||||
vbox.getChildren().set(1, region);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
region.requestFocus();
|
||||
cb.showingProperty().addListener((observable, oldValue, newValue) -> {
|
||||
if (!newValue && vbox.getChildren().size() > 1) {
|
||||
vbox.getChildren().get(1).requestFocus();
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue