scijava / scijava-common

A plugin framework and application container with built-in extensibility mechanism :electric_plug:
BSD 2-Clause "Simplified" License
91 stars 52 forks source link

Weirdness when setting multiple-choice input options dynamically #470

Open ctrueden opened 1 year ago

ctrueden commented 1 year ago

From a Zulip topic by @emilmelnikov:

In the following example, target should be a dropdown list populated with values derived from other inputs when they change, but target renders as a normal text field. ```java public class SampleCommand extends DynamicCommand { @Parameter(label = "Input", callback = "inputChanged") String input; @Parameter(label = "Target", style = "listBox") String target; void inputChanged() { MutableModuleItem item = getInfo().getMutableInput("target", String.class); item.setChoices(Arrays.asList("one", "two", "three")); } } ``` It works when choices = {" "} is passed to `@Parameter` with `listBox`. Note the single space: passing an empty string results in `NullPointerException`.