|
1 | 1 | package edu.wpi.first.shuffleboard.plugin.base.widget;
|
2 | 2 |
|
| 3 | +import edu.wpi.first.shuffleboard.api.widget.ComplexAnnotatedWidget; |
| 4 | +import edu.wpi.first.shuffleboard.api.widget.Description; |
| 5 | +import edu.wpi.first.shuffleboard.api.widget.ParametrizedController; |
3 | 6 | import edu.wpi.first.shuffleboard.plugin.base.data.SendableChooserData;
|
4 | 7 | import edu.wpi.first.shuffleboard.plugin.base.data.types.SendableChooserType;
|
5 | 8 |
|
6 | 9 | import java.util.Map;
|
7 | 10 |
|
8 |
| -import edu.wpi.first.shuffleboard.api.widget.ComplexAnnotatedWidget; |
9 |
| -import edu.wpi.first.shuffleboard.api.widget.Description; |
10 |
| -import edu.wpi.first.shuffleboard.api.widget.ParametrizedController; |
11 | 11 | import javafx.fxml.FXML;
|
12 | 12 | import javafx.scene.control.ComboBox;
|
13 | 13 | import javafx.scene.layout.Pane;
|
@@ -37,7 +37,16 @@ private void initialize() {
|
37 | 37 | });
|
38 | 38 | comboBox.getSelectionModel()
|
39 | 39 | .selectedItemProperty()
|
40 |
| - .addListener((__, oldValue, newValue) -> setData(getData().withSelectedOption(newValue))); |
| 40 | + .addListener((__, oldValue, newValue) -> { |
| 41 | + SendableChooserData currentData = getData(); |
| 42 | + if (newValue == null) { |
| 43 | + String defaultOption = currentData.getDefaultOption(); |
| 44 | + setData(currentData.withSelectedOption(defaultOption)); |
| 45 | + comboBox.getSelectionModel().select(defaultOption); |
| 46 | + } else { |
| 47 | + setData(currentData.withSelectedOption(newValue)); |
| 48 | + } |
| 49 | + }); |
41 | 50 | }
|
42 | 51 |
|
43 | 52 | private void updateOptions(String... options) {
|
|
0 commit comments