Class RadioButton
ButtonGroup are mutually exclusive: selecting one deselects the rest.
Unlike a Checkbox, clicking a selected radio does not turn it
off. Selected by click, or Space/Enter when focused. Colours from Theme,
extents from the SizeTokens row resolved on this widget, pens from
Strokes.
The ring rides indicator, the same token as Checkbox's
box, so a form mixing the two keeps every label on one optical column at every
step.
The ring sits on the row's leading edge with the label running away from it, so
both swap sides with the LayoutDirection resolved on this widget. The ring
is a circle and the dot is concentric with it, so nothing inside the indicator has a side to
reflect; only the column the pair occupies moves.
This row is under the 24 pt pointer target
The row ismax(indicator, lineHeight) rather than the control-height ramp, and the
indicator wins that max at every step (18 pt at MEDIUM), which is below the 24 pt target
of WCAG 2.2 SC 2.5.8 (AA) on the axis that decides it: a label widens a target, it never
heightens it. A radio's pointer target is exactly the ring-and-label box it paints.
The standard's own Spacing exception is what an application relies on: an
undersized target conforms while a 24 pt circle centred on it clears every neighbour. A
lone radio already satisfies that; a group (the normal case) does not until the pitch
reaches 24, which is what Tokens.toggleColumnGap(limn.scene.Widget) gives. Stack
a ButtonGroup's radios on that gap, not a tighter one.
-
Constructor Summary
ConstructorsConstructorDescriptionRadioButton(String text) A radio with a fixed label; see theI18nStringconstructor for localized text.RadioButton(I18nString text) A radio button whose label follows the UI language; seeI18nString. -
Method Summary
Modifier and TypeMethodDescriptionprotected floatDistance from this widget's top edge to its first text baseline, in logical points: the alignment reference forFlex.CrossAlignment.BASELINE.booleanWhether this radio is the selected one in its group.Fires withtruewhen this radio becomes selected,falsewhen a sibling takes over.protected voidCalled when this widget takes keyboard focus.protected voidCalled when this widget loses keyboard focus.protected voidonKeyEvent(KeyEvent event) Key events (focused widget first, then ancestors).protected SizeonMeasure(Constraints constraints) Reports the size this widget wants withinconstraints.protected voidonMouseEvent(MouseEvent event) Mouse events (bubbling); callevent.consume()when handled.protected voidWidget's own background/content, in local coordinates.protected floatThe focus circle is the only thing that paints outside the box: radiusring/2 +Strokes.FOCUS_GAP_INDICATORwith a centredStrokes.FOCUS_RING_THINpen puts its outer ink 2.25pt past the indicator, which is flush with the widget's leading edge — the left one reading left to right and the right one reading right to left — and (since the row is the indicator at every step) with its top and bottom.voidselect()Selects this radio (idempotent).Replaces the label with a fixed string.Methods inherited from class limn.scene.Widget
acceptsTextInput, add, baselineOffsetOf, caretRect, children, clipboard, clipsChildren, controlSize, cursor, declaredControlSize, declaredLayoutDirection, declaredLocale, focusArrivedByTraversal, height, hitTest, imageCursor, invalidate, invalidate, isEnabled, isFocusable, isFocused, isShowing, isVisible, layoutBox, layoutDirection, locale, localToSceneX, localToSceneY, markNeedsContainedLayout, markNeedsLayout, measure, moveChild, neutralBase, onAttached, onCharTyped, onDetached, onFileDrop, onLayout, onPaintOverlay, onPreedit, overlayPassesPointer, paintChildren, paintWidget, parent, remove, requestFocus, revealInView, scene, sceneToLocalX, sceneToLocalY, setControlSize, setCursor, setEnabled, setFocusable, setImageCursor, setInheritanceHost, setLayoutDirection, setLocale, setTooltip, setTooltip, setVisible, shapeText, textRuler, tooltip, width, x, y
-
Constructor Details
-
RadioButton
A radio with a fixed label; see theI18nStringconstructor for localized text. -
RadioButton
A radio button whose label follows the UI language; seeI18nString.
-
-
Method Details
-
onChange
Fires withtruewhen this radio becomes selected,falsewhen a sibling takes over. -
setText
Replaces the label with a fixed string. UI thread only. -
isSelected
public boolean isSelected()Whether this radio is the selected one in its group. -
select
public void select()Selects this radio (idempotent). In a group, deselects the previously selected sibling and notifies the group; standalone, just selects itself. -
onMeasure
Description copied from class:WidgetReports the size this widget wants withinconstraints. Called once per layout pass, and the result is cached against the constraints and the resolved axes (size step, layout direction, locale), so it must be a pure function of them and of this widget's own state.Resolve the
ControlSizeand theLayoutDirectiononce each here and thread them down; never read either in a constructor. The locale needs no threading: it is in scope, andI18n.locale()answers it wherever text is resolved. -
baselineOffset
protected float baselineOffset()Description copied from class:WidgetDistance from this widget's top edge to its first text baseline, in logical points: the alignment reference forFlex.CrossAlignment.BASELINE. Defaultheight(): align on the bottom edge, the correct fallback for a widget with no text. Text-bearing components override with the expression they already paint with,(height() - metrics.height()) / 2 + metrics.ascent().Valid only once this widget has been given a box.
Flexguarantees that: it lays every child of a BASELINE line out at cross position 0 first, reads the baselines, then repositions withWidget.moveChild(limn.scene.Widget, float, float), which moves without re-running layout.- Overrides:
baselineOffsetin classWidget
-
onPaint
Description copied from class:WidgetWidget's own background/content, in local coordinates. -
paintOutset
protected float paintOutset()The focus circle is the only thing that paints outside the box: radiusring/2 +Strokes.FOCUS_GAP_INDICATORwith a centredStrokes.FOCUS_RING_THINpen puts its outer ink 2.25pt past the indicator, which is flush with the widget's leading edge — the left one reading left to right and the right one reading right to left — and (since the row is the indicator at every step) with its top and bottom. One outset covers every side, so the edge the indicator moves to is already inside the damage and the direction is not an input here.Sceneassumes only 1pt of AA feather, so without this the fading ring left stale pixels under partial rendering. Deliberately the same expression asCheckbox's: the two are in declared lockstep and must damage the same rectangle, or a form column mixing them repaints unevenly.- Overrides:
paintOutsetin classWidget
-
onMouseEvent
Description copied from class:WidgetMouse events (bubbling); callevent.consume()when handled.- Overrides:
onMouseEventin classWidget
-
onKeyEvent
Description copied from class:WidgetKey events (focused widget first, then ancestors).- Overrides:
onKeyEventin classWidget
-
onFocusGained
protected void onFocusGained()Description copied from class:WidgetCalled when this widget takes keyboard focus. Default: nothing.- Overrides:
onFocusGainedin classWidget
-
onFocusLost
protected void onFocusLost()Description copied from class:WidgetCalled when this widget loses keyboard focus. Default: nothing.- Overrides:
onFocusLostin classWidget
-