Skip to content

GemNumberInput

The component is an input field for numeric values with an optional label.

Usage Example

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

import mc.fenix.input.GemNumberInput;
import common.ExamplePage;
import mc.fenix.arrange.GemColumn;
import mc.fenix.input.GemTextInputTypes.GemTextInputValidity;

page GemNumberInputExample(double priceEntry, int quantityEntry) {
  @ExamplePage(
    component = @GemColumn(components = [
      @GemNumberInput(
        id = "price",
        labelText = "Stock Price (€, double variable):",
        entry = priceEntry,
        placeholder = "Enter price..."
      ),
      @GemNumberInput(
        id = "quantity",
        labelText = "Quantity (int variable, step 1.0):",
        entry = quantityEntry,
        placeholder = "Enter quantity..."
      ),
      @GemNumberInput(
        id = "rating",
        labelText = "Decimal Rating (step 0.5):",
        step = 0.5,
        placeholder = "Enter rating e.g. 4.5..."
      ),
      @GemNumberInput(
        id = "disabledNumber",
        labelText = "Disabled Number Input:",
        disabled = true
      ),
      @GemNumberInput(
        id = "invalidNumber",
        labelText = "Number Input with Error:",
        validity = GemTextInputValidity("Error", "Invalid number range")
      )
    ]),
    basePath = "example_input",
    componentName = "GemNumberInputExample"
  );
}
GemNumberInputExample

GUI Model

component GemNumberInput(
  String id,
  String labelText = "",
  ?double entry,
  double step = 1.0,
  boolean disabled = false,
  String placeholder = "",
  String width = "100%",
  String height = "100%",
  GemTextInputValidity validity,
  Event<Object> keyRelease,
  Event<Object> keyPress
)
Name Type Description Default value
id String The component's id; used to configure the styles.
labelText String Text describing the input field. ""
entry ?double 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.
step double Step increment for the number input. Default is 1.0. 1.0
disabled boolean Whether the input field is disabled. false
placeholder String Text displayed when the field is empty. ""
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.
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

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