Loading
Docs / Components / Dropdowns
v1.0.0 JAVA MOD LIBRARY

Dropdowns

Button-styled selector that defers a centered modal menu popup to ui.end().

ui.dropdown(...) draws a 26px tall (OreUi.BUTTON_HEIGHT) OreVariant.GENERAL trigger with left-aligned selection text and a right-aligned OreIcon.CHEVRON_DOWN.small glyph. When open is true, OreUi automatically defers rendering of the modal option popup (280px wide with overlay, block, popupHeader, and clipped menuButton rows) to ui.end(), keeping it clear of scroll panes and cards.

Selected difficulty: normal (click to open Popup menu)

Behavior

  • Deferred modal layer: Because the option popup renders during ui.end(), dropdowns work seamlessly inside OrePanelScreen scroll views and cardContainer slots without getting clipped.
  • Input isolation: Calling ui.block() inside the deferred popup ensures clicking an option or closing the popup never triggers widgets underneath.
  • Single selection: Clicking an option invokes onSelect.accept(index) and calls toggle.run() to close the popup.

Method Signature (OreUi)

public void dropdown(int x, int y, int w, String selected, String[] options,
                     boolean open, String key, String tip,
                     Runnable toggle, IntConsumer onSelect)

Parameters

ParameterTypeDescription
x, y, wintTrigger coordinates and width (height is OreUi.BUTTON_HEIGHT = 26).
selectedStringCurrently selected display text drawn inside the trigger button.
optionsString[]Array of option strings listed as menuButton rows when open is true.
openbooleanControls whether the deferred selection popup is rendered.
keyStringUnique animation key ("dropdown:" + key).
tipStringOptional hover tooltip on the trigger button.
toggleRunnableInvoked when clicking the trigger or the popup’s close button.
onSelectIntConsumerInvoked with the selected 0-based index when an option is clicked.

Example

private boolean dropdownOpen = false;
private int difficultyIndex = 2;
private final String[] difficulties = { "Peaceful", "Easy", "Normal", "Hard" };

ui.dropdown(x, y, 180, difficulties[difficultyIndex], difficulties, dropdownOpen,
	"diffDrop", "Choose difficulty",
	() -> dropdownOpen = !dropdownOpen,
	idx -> {
		difficultyIndex = idx;
		dropdownOpen = false;
	});