label: (Panel, string, PanelLabelOptions?) -> ()
One line of text: the alternative to a JLabel. Its setters are the options: setFont/setForeground (the text options), setHorizontalAlignment (align), setIcon (icon, an Image or any image source), setToolTipText (tooltip).
heading: (Panel, string, PanelLabelOptions?) -> ()
label in the panel's heading style.
selectableLabel: (Panel, string, boolean, Color?) -> boolean
A label that takes clicks, highlighted while selected.
text- The text.
selected- Whether it draws selected.
color- For a state the three theme tokens cannot name.
- Returns
true only on the frame it was clicked.
rowSpans: (Panel, { RowSpan }, boolean, RowOpts?) -> (boolean, boolean)
ONE full-width, single-line, selectable row assembled out of styled runs, so a tree row can colour its name, its id and its text differently and still hover, highlight and click as the single row it looks like. Returns (rowClicked, twistClicked) — the twist has its own hit region, so folding a node does not also select it. width on a run fixes a column and truncates with an ellipsis; bg on a run is the search-match highlight.
local clicked, folded = panel:rowSpans(
{ { text = name, color = Color.ORANGE }, { text = tostring(id), mono = true } },
selected == id,
{ indent = depth * 12, twist = open and "open" or "closed" }
)
button: (Panel, string, PanelButtonOptions?) -> boolean
A push button: the alternative to JButton + addActionListener. new JButton(text, icon) / setIcon is the icon option (an Image or any image source; an empty text draws the icon alone), setBackground fill, setPreferredSize width/height, setContentAreaFilled(false) frame = false, setEnabled enabled.
- Returns
true only on the frame it was clicked.
iconButton: (Panel, PanelIconName, string) -> boolean
A small square button drawn as an icon.
icon- Which icon. Another string raises.
hover- Tooltip text.
- Returns
true only on the frame it was clicked.
checkbox: (Panel, string, boolean, PanelCheckOptions?) -> boolean
A labelled checkbox: the alternative to JCheckBox + addItemListener; the plugin keeps the state.
label- Text beside the box.
checked- Current state.
- Returns
- The new state. Assign it back.
toggleValue: (Panel, string, boolean, PanelButtonOptions?) -> boolean
A toggle *button* — filled when on, not a checkbox: the alternative to JToggleButton. The options are button's (icon for an icon toggle).
label- Button text.
selected- Current state.
- Returns
- The new state. Assign it back.
- Example
on = panel:toggleValue("NPCs", on)
textEdit: (Panel, string, PanelTextEditOptions?) -> (string, boolean)
A single-line text field: the alternative to JTextField (and JPasswordField, password). setEditable(false) is readOnly, requestFocusInWindow focus, setPreferredSize width/height. Without a width the field is 280 wide, which is wider than some panes and pushes whatever follows the field off the edge.
- Returns
- The text, and whether Enter was pressed in the field this pass (
addActionListener).
separator: (Panel) -> ()
A horizontal rule across the available width: the alternative to JSeparator.
addSpace: (Panel, number) -> ()
Blank vertical space.
points- How much space to add.
copyRequested: (Panel) -> boolean
Did this frame see a copy command (Ctrl+C / Cmd+C)? So a plugin that draws its own selectable content can answer the normal copy gesture rather than growing a Copy button beside it. egui routes the same event to a focused text field, so only act on this when nothing of your own has focus.
modifiers: (Panel) -> { shift: boolean, ctrl: boolean, alt: boolean, command: boolean }
Keyboard modifiers held this frame, so a plugin can offer range and additive selection: { shift, ctrl, alt, command }.
availableWidth: (Panel) -> number
Width left on the current row, in points.
horizontal: (Panel, (Panel) -> ()) -> ()
Lay the body out left to right on one row.
body- Called immediately, with the row's own
ui.
rightToLeft: (Panel, (Panel) -> ()) -> ()
Lay the body out right to left, for trailing controls on a row.
body- Called immediately, with the row's own
ui.
indent: (Panel, (Panel) -> ()) -> ()
Indent the body one level.
body- Called immediately, with the indented
ui.
group: (Panel, (Panel) -> ()) -> ()
Draw the body inside a bordered group.
body- Called immediately, with the group's own
ui.
scrollArea: (Panel, (Panel) -> (), PanelScrollOptions?) -> (number, number, number)
Draw the body inside a vertical scroll area: the alternative to JScrollPane (a default PluginPanel scrolls; the host does not wrap the panel).
body- Called immediately, with the scrolled
ui. - Returns
- The scroll offset (
getVerticalScrollBar().getValue()), the content's height and the view's height.
collapsing: (Panel, string, (Panel) -> (), boolean?) -> ()
A collapsible section with a disclosure triangle.
label- Header text; also its identity between frames.
body- Called immediately when open, with the section's
ui. defaultOpen- Open on first sight. Defaults to closed.
grid: (Panel, string, number, (Panel) -> (), PanelGridOptions?) -> ()
A striped, column-aligned grid: the alternative to GridLayout, GroupLayout and JTable. Call endRow to finish each row. Equal cells (GridLayout) set minColWidth and maxColWidth to one width; spacingX/spacingY are its hgap/vgap.
id- Identity between frames; must be unique in this panel.
columns- How many columns.
body- Called immediately, with the grid's own
ui.
- Example
function plugin:sidePanel(panel: Panel)
-- Two columns; each row ends with endRow.
panel:grid("kills", 2, function(grid)
grid:label("Monster")
grid:label("Kills")
grid:endRow()
for _, row in kills do
grid:label(row.name)
grid:label(tostring(row.count))
grid:endRow()
end
end, { striped = true })
end
columns2: (Panel, (Panel) -> (), (Panel) -> (), number?) -> ()
A two-pane split. ratio is the left pane's share of the width (0.5 when omitted, clamped to 0.15..0.85); a tree pane and a key/value pane rarely want the same width. Each pane has its own id namespace, so sibling scroll areas do not share a scroll offset.
endRow: (Panel) -> ()
End the current row inside a grid body.
copyText: (Panel, string) -> ()
Put text on the system clipboard.
text- What to copy.
frame: (Panel, (Panel) -> (), PanelFrameOptions?) -> (boolean, boolean)
A framed group: a border, a fill, margins. The alternative to JComponent#setBorder (EmptyBorder, LineBorder, MatteBorder, nested for a CompoundBorder), setBackground, and a mouseEntered hover background (hoverFill). The body is laid out as the frame's parent lays out (left to right inside a horizontal row); for a vertical column inside a row, use aligned.
body- Draws the frame's contents.
- Returns
- Whether the frame was clicked (with
clickable), and whether it is hovered.
sized: (Panel, (Panel) -> (), PanelSizedOptions) -> ()
Lay the body out in a region of a set size: the alternative to setPreferredSize/setMinimumSize/setMaximumSize.
body- Draws the contents; taller content overflows, as in Swing without a scroll pane.
aligned: (Panel, "left" | "center" | "right" | "fill", (Panel) -> ()) -> ()
Lay the body's items out top to bottom, aligned: the alternative to setHorizontalAlignment, and to a vertical BoxLayout panel or a GroupLayout parallel group inside a row (aligned("left", body) in a horizontal row stacks body's items in a column beside the rest).
align"fill" stretches every item to the width, a BorderLayout.CENTER. Another string raises.
enabled: (Panel, boolean, (Panel) -> ()) -> ()
Grey out and disable everything in the body when on is false: the alternative to JComponent#setEnabled(false) on a container.
image: (Panel, PanelImageSource, PanelImageOptions?) -> boolean
An image: the alternative to new JLabel(new ImageIcon(img)). img is an Image (a BufferedImage/AsyncBufferedImage: drawn from its pixels in Rust, uploaded again only when they change), PNG bytes, or a PanelImageSpec. A game sprite, and an AsyncBufferedImage before it loads, take their room and draw nothing.
- Returns
- Whether it was clicked.
canvas: (Panel, number, number, (Graphics2D) -> (), PanelCanvasOptions?) -> boolean
A Graphics2D canvas drawn into an image: the alternative to overriding JComponent#paintComponent. draw runs on every pass unless opts.key is unchanged, which reuses the last pixels. The Graphics2D is good only while draw runs: one kept past it raises.
panel:canvas(200, 20, function(g)
g:setColor(Color.GREEN)
g:fillRect(0, 0, 200 * health, 20)
end, { key = tostring(health) })
width- Width, clamped to 1..2048.
height- Height, clamped to 1..2048.
draw- Paints the canvas.
- Returns
- Whether it was clicked;
lastResponse has the details.
spinner: (Panel, number, PanelSpinnerOptions?) -> number
A drag-or-type number field: the alternative to JSpinner with a SpinnerNumberModel (and JFormattedTextField).
- Returns
- The value, clamped to
min..max.
combo: (Panel, string, number?, { string }, PanelComboOptions?) -> number
A drop-down: the alternative to JComboBox.
id- The control's identity.
selected- 1-based index into
items; nil or 0 selects nothing. items- The labels.
- Returns
- The selected index.
radio: (Panel, string, boolean, PanelCheckOptions?) -> boolean
One radio button: the alternative to JRadioButton in a ButtonGroup. The plugin keeps the group's choice.
- Returns
- Whether it was clicked.
textEditMultiline: (Panel, string, PanelTextAreaOptions?) -> string
A wrapping multi-line text field: the alternative to JTextArea (setLineWrap(true), setRows rows, setEditable(false) readOnly; fill takes the height left, as a BorderLayout.CENTER text area does).
- Returns
- The text.
hyperlink: (Panel, string, string, PanelCheckOptions?) -> boolean
A link: the alternative to a link JLabel and LinkBrowser.browse. Only http and https, opened at once on a click. A marketplace plugin's link must be https to oldschool.runescape.wiki, runescape.wiki or runescape.com (or a subdomain of one); any other raises.
- Returns
- Whether it was clicked.
lastResponse: (Panel) -> PanelResponse?
How the LAST control drawn was used this pass: the alternative to a MouseListener/FocusListener.
availableHeight: (Panel) -> number
scrollRows: (Panel, number, number, (Panel, number, number) -> (), PanelScrollOptions?) -> number
Only the rows in view of a long list: the alternative to a JList over a large model in a JScrollPane. Each row is rowHeight tall.
body- Gets the panel and the 1-based, inclusive range of visible rows.
- Returns
- The scroll offset in points.
tooltip: (Panel, PanelTooltip) -> ()
A tooltip on the LAST control drawn: the alternative to setToolTipText for a control that took no tooltip option. Text, styled runs (an <html> tooltip's colour spans), or a function that draws the tooltip with Panel controls (a progress bar in it). Runs are read and laid out only while the tooltip shows; runs that do not read show why there (as the tooltip option's do), rather than raise. With no control drawn before it in this pass, it raises.