EventChooser
com.jsmacrosce.jsmacros.client.gui.overlays.EventChooser
Displays registered event names in a five-column overlay and lets the caller confirm a selection.
Closing or cancelling does not invoke the callback. In this factory the caller supplies an IOverlayParent, native Font, non-null initial event name and JavaScript callback:
js
function showEventChooser(parent, font, selected, onSelected) {
const EventChooser = Java.type('com.jsmacrosce.jsmacros.client.gui.overlays.EventChooser');
const chooser = new EventChooser(10, 10, 300, 180, font, selected, parent, JavaWrapper.methodToJava(onSelected));
parent.openOverlay(chooser);
return chooser;
}The callback runs on confirmation only when both a selection and callback are non-null. An arbitrary non-null selection can be confirmed, whether or not it is in the registered event list. Confirmation closes the overlay only after the callback returns normally; a missing callback leaves the Select button without this action.
Nested types
Constructors
new EventChooser
new EventChooser(int x, int y, int width, int height, Font textRenderer, String selected, IOverlayParent parent, Consumer<String> setEvent)#Stores the overlay geometry, initial selection, parent, and optional confirmation callback; the constructor does not open the overlay or initialize its widgets.
Parameters:
x: left edge in GUI coordinatesy: top edge in GUI coordinateswidth: overlay width in GUI coordinatesheight: overlay height in GUI coordinatestextRenderer: non-null font used for overlay text and buttonsselected: initial event name; must be non-null if the initialized event list is nonempty, but need not name a registered eventparent: non-null overlay parentsetEvent: nullable callback invoked on confirmation when a selection is non-null
Methods
addEvent
Appends an event row after existing rows and updates the scrollbar range; this does not sort, deduplicate, or register the name. Requires the scrollbar created by
init. Uses an available translation for "jsmacrosce.event." plus the name lowercased with Locale.ROOT, otherwise the literal name. Adding a row does not select or highlight it, even if its name matches the current selection.Parameters:
eventName: non-null event name represented by the row and selected when its button is clicked
init
init(): void#Initializes the overlay controls, copies and sorts the registered event names, and adds rows before applying the current selection. Requires an initialized client event registry and a non-null selection when there are rows. Repeated calls reset the scroll position and container button tracking but retain prior rows, so they append duplicate rows and are not a refresh operation. Previously registered parent widgets are not removed.
onScrollbar
onScrollbar(double page): void#Applies an unclamped scrollbar offset and repositions rows; visibility uses row top edges, not full-row clipping. Sets the row origin to
y + 13 - (int) (page * (height - 27)).Parameters:
page: scroll offset in units ofheight - 27GUI coordinates, not a normalized percentage
render
render(GuiGraphics drawContext, int mouseX, int mouseY, float delta): void#Submits the background, caption and separators, forwards the hook to widgets and a child overlay, then submits full-label popups for tracked buttons with the stored hovering flag and truncated text. Neither the inherited visibility flag nor the popup button's visibility or active flag is checked here.
Parameters:
drawContext: context receiving the overlay and widget drawing operationsmouseX: mouse x-coordinate in GUI coordinates, forwarded to widgets and used to position label popupsmouseY: mouse y-coordinate in GUI coordinates, forwarded to widgets and used to position label popupsdelta: frame value forwarded to widgets
selectEvent
updateEventPos
updateEventPos(): void#Repositions retained rows from the current overlay geometry and scroll offset, updating visibility from each row's top edge. Rows use five columns with 12-unit row heights. Visibility checks whether each row's top is within the inclusive interval from
y + 13 to y + height - 27, not whether its full bounds fit. This does not change the scroll offset or recompute the scrollbar range.