Dropdown()

Creates a Material Design select dropdown form element. Dropdowns transform native HTML select elements into styled Material Design components.

Syntax
Result = MaterialSB::Dropdown(Label.s = "", Flags = #Dropdown_Default, Parent = #Null)
Parameters
Label.s Optional. Label text displayed above the dropdown.
Flags Optional. Combination of dropdown flags for styling and behavior.
Parent Optional. Parent element. If #Null, uses the current parent from the stack.
Flags
FlagDescription
#Dropdown_DefaultStandard select dropdown (default)
#Dropdown_OutlinedOutlined style input field
#Dropdown_MultipleAllow multiple selections
#Dropdown_DisabledDisabled state
Return Value

Returns the select element. Use this reference for Init(), DropdownAddOption(), and GetValue().

Remarks

Important: Dropdown requires Init() to be called after adding all options. Without initialization, the dropdown will not render properly.

Use DropdownAddOption() to add options to the dropdown. Use GetValue() to retrieve the currently selected value.

Example
Global myDropdown

Procedure ShowSelection()
  Protected value.s
  !v_value = v_mydropdown.value;
  MaterialSB::Toast("Selected: " + value)
EndProcedure

Procedure Main(Success)
  If Success
    MaterialSB::Row(MaterialSB::#Grid_Container)
      MaterialSB::Col(12, 6, 4)
        ; Create dropdown
        myDropdown = MaterialSB::Dropdown("Choose a country")
        
        ; Add options
        MaterialSB::DropdownAddOption("Select...", "", myDropdown, #True)
        MaterialSB::DropdownAddOption("United States", "us", myDropdown)
        MaterialSB::DropdownAddOption("United Kingdom", "uk", myDropdown)
        MaterialSB::DropdownAddOption("Canada", "ca", myDropdown)
        MaterialSB::DropdownAddOption("Australia", "au", myDropdown)
        MaterialSB::DropdownAddOption("Germany", "de", myDropdown)
        
        ; Initialize the dropdown
        MaterialSB::Init(myDropdown, #Null)
        
        ; Add callback for changes
        MaterialSB::InputSetCallback(myDropdown, @ShowSelection())
        
      MaterialSB::CloseCurrentParent()
    MaterialSB::CloseCurrentParent()
  EndIf
EndProcedure

MaterialSB::Download(@Main())
See Also

DropdownAddOption(), Init(), GetValue(), InputSetCallback()