Skip to content

GemAutocompleteInput

The component is a dropdown field with an optional label. It is used whenever a user input is required, in which the user selects one from multiple options

Usage Example

/* (c) https://github.com/MontiCore/monticore */
package example_input;

import mc.fenix.input.GemAutocompleteInput;
import mc.fenix.input.GemDropdownInputTypes.Option;
import mc.fenix.arrange.GemColumn;
import mc.fenix.arrange.GemRow;
import common.ExamplePage;

page GemAutocompleteInputExample() {
  @ExamplePage(
    component = @GemColumn(components = [
      @GemRow(
        components = [
          @GemAutocompleteInput(
            id = "searchEngines",
            width = "50%",
            labelText = "Search engine:",
            placeholder = "Type here ...",
            options = [
              Option("DuckDuckGo"),
              Option("Ecosia"),
              Option("Bing"),
              Option("Google"),
              Option("Baidu")
            ]
          )
        ]
      ),
      @GemColumn(
        rowGap = "15px",
        components = [
          @GemRow(
            components = [
              @GemAutocompleteInput(
                width = "50%",
                labelText = "Hobby:",
                options = [
                  Option("Tennis"),
                  Option("Sleeping"),
                  Option("Model-driven development"),
                  Option("Video gaming"),
                  Option("Photographing"),
                  Option("Bouldering"),
                  Option("Football"),
                  Option("Drawing"),
                  Option("Social Media"),
                  Option("Knitting"),
                  Option("Volleyball"),
                  Option("Running"),
                  Option("Swimming"),
                  Option("Reading"),
                  Option("Music"),
                  Option("Movies"),
                  Option("Hiking"),
                  Option("Climbing"),
                  Option("Travelling"),
                  Option("Scuba diving"),
                  Option("Hacking"),
                  Option("Cooking"),
                  Option("Gardening"),
                  Option("Other")
                ]
              )
            ]
          )
        ]
      )
    ]),
    basePath = "example_input",
    componentName = "GemAutocompleteInputExample"
  );
}
GemAutocompleteInputExample

GUI Model

component GemAutocompleteInput(
  String id,
  String labelText = "",
  List<Option> options,
  ?String entry,
  boolean disabled = false,
  String width = "100%",
  String height = "100%",
  GemTextInputValidity validity,
  String placeholder = "",
  Event<Object> keyRelease,
  Event<Object> keyPress
)
Name Type Description Default value
id String Can be set to ensure the list of options is specific to the input field.
labelText String Text describing the input field. ""
options List<Option> A list of options for the autocomplete suggestions
entry ?String The input field's value. If it is linked to a variable, the value of the variable will change when the user enters a new value.
disabled boolean Whether the input field is disabled. false
width String Width of the input field. "100%"
height String Height of the input field. "100%"
validity GemTextInputValidity An object representing the validation status of the field.
placeholder String Text displayed when the field is empty. ""
keyRelease Event<Object> Callback that is executed when a key is released.
keyPress Event<Object> Callback that is executed when a key is pressed.

Types

GemDropdownInputTypes

package mc.fenix.input;

classdiagram GemDropdownInputTypes {

  public class Option {
    String value;
    String display;
    +Option(String value);
    +Option(String value, String display);
  }

}

Option

Name Type Description Default value
value String Value behind the option in a dropdown. An option typically represents an object, e.g. person, via human-readable name. The value is an identifier that represents the object in the logic implementation.
display String Human-readable name representing the option.

GemTextInputTypes

package mc.fenix.input;

classdiagram GemTextInputTypes {

  public class GemTextInputValidity {
    String status;
    String message;
    +GemTextInputValidity(String status);
    +GemTextInputValidity(String status, String message);
  }

}

GemTextInputValidity

Name Type Description Default value
status String The validation status. Possible values: "Error": There is a problem or issue that needs attention. "Unchecked": The input has not been inspected. "Success": Positive validation result. "Warning": There is a potential issue that should be noted.
message String A message to be displayed as a tooltip with the status