Commit ea38af2a authored by Axel Howind's avatar Axel Howind

set initial focus

parent cb8288ba
Pipeline #51579444 failed with stages
in 17 minutes and 38 seconds
package com.dua3.fx.util.controls;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.function.Supplier;
import java.util.logging.Logger;
import com.dua3.fx.util.FxUtil;
import javafx.beans.binding.Bindings;
import javafx.beans.binding.BooleanBinding;
import javafx.beans.binding.BooleanExpression;
......@@ -24,6 +13,11 @@ import javafx.scene.control.ButtonType;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import java.util.*;
import java.util.concurrent.Callable;
import java.util.function.Supplier;
import java.util.logging.Logger;
public class InputPane extends InputDialogPane<Map<String,Object>> {
/** Logger */
......@@ -151,6 +145,11 @@ public class InputPane extends InputDialogPane<Map<String,Object>> {
valid.bind(binding);
setContent(grid);
for (var entry: data) {
entry.control.node().requestFocus();
break;
}
}
}
package com.dua3.fx.util.controls;
import java.util.function.Supplier;
import java.util.logging.Logger;
import javafx.scene.control.TextField;
import javafx.scene.layout.StackPane;
import java.util.function.Supplier;
import java.util.logging.Logger;
public class PromptPane extends InputDialogPane<String> {
/** Logger */
......@@ -27,6 +27,7 @@ public class PromptPane extends InputDialogPane<String> {
@Override
public void init() {
text.requestFocus();
updateValidState(text.getText());
}
}
......@@ -6,6 +6,7 @@ import javafx.beans.property.ReadOnlyStringProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.ObservableList;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.RadioButton;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleGroup;
......@@ -92,4 +93,23 @@ public class RadioPane<T> extends VBox implements InputControl<T> {
public void reset() {
state.reset();
}
@Override
public void requestFocus() {
if (group.getToggles().isEmpty()) {
super.requestFocus();
}
Toggle t = group.getSelectedToggle();
if (t==null) {
t = group.getToggles().get(0);
}
if (t instanceof Control) {
((Control) t).requestFocus();
} else {
super.requestFocus();
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment