Skip to content

BaseToggleNode

abstract class BaseToggleNode<F, S>
Extends: Node
Known subtypes: ToggleNode
Package: dev.joid.lib.ui.node.impl.control.toggle · Module: core · Source: BaseToggleNode.java

The behavior of a toggle without its look: a boolean that a left press switches, and the two values it stands for.

Extend ToggleNode for a look made of a track and a knob; extend BaseToggleNode only to build the look entirely yourself. F is the type of the value when the toggle is on, S when it is off.

ReturnsSignatureSummary
BaseToggleNode(double x, double y, double width, double height) protectedCreates the toggle at x, y with a width and a height in design pixels, from the constructor of a skin.

Inherited from Node (24)

x · y · width · height · position · anchor · anchorX · anchorY · aspectRatio · zindex · zlevel · skeleton · visible · enabled · interactive · cursor · hoverDuration · hoverEquation · hover · overflow · scrollSpeed · scrollbar · label · draggable

ReturnsSignatureSummary
TgetValue()Returns the value that the toggle stands for: the first value of state(...) while it is on, the second one while it is off, or a Boolean without a state.
thisstate(F toggle, S back) fluentGives the two values that getValue() returns, such as "Night" and "Day"; it does not change whether the toggle is on.
Ttoggle(boolean toggle)Gives the toggle its start value: true is on; a toggle attached already fires onChange when it differs.
Ttoggle(Signal toggle)Binds the on state to a signal both ways: the toggle shows the signal, and a press writes the new state into it.
thischange(boolean toggle) fluentSets the state as if the user pressed the toggle: beforeChange can refuse it, then onChange fires.
TbeforeChange(EventListener<NodeChangeEvent.Pre<T,Boolean>> listener)Adds a listener that runs before a change that a press or change(...) asks for; cancel() refuses it.
booleanisToggle()If true, the toggle is on.
ToggleState<F,S>getState()Returns the pair given to state(...), or null before it.
ReturnsSignatureSummary
voidmousePressed(NodeMouseEvent<?> event) hookSwitches the state on a left press over the toggle that no one consumed, and consumes the press.
Inherited from Node (128)

load · render · renderHover · updateScroll · updateScrollX · updateScrollY · append · attach · body · clearChildren · getChild · getChildren · getNodeListAt · getParent · isAttached · getAbsoluteX · getAbsoluteY · getAbsoluteDefaultX · getAbsoluteDefaultY · toDrawX · toDrawY · w · h · dw · dh · mw · mh · aw · ah · ax · ay · getDefaultWidth · getDefaultHeight · removeHover · clearHover · refreshHover · getResolvedCursor · hoverValue · getHoverAnimator · isHovered · handleMousePressed · handleMouseReleased · handleMouseDragged · handleMouseScroll · handleCharTyped · handleKeyPressed · handleKeyReleased · getLastClickTime · getLastClickButton · getLastKey · getLastKeyTime · scrollX · scrollY · scrollTo · beforeScroll · hasOverflowX · hasOverflowY · getOverflowArea · getScrollX · getScrollY · getTargetScrollX · getTargetScrollY · getMaxScrollX · getMaxScrollY · isScrollEndX · isScrollEndY · startDragging · stopDragging · beforeDragStart · beforeDragDrop · isDragging · getDragX · getDragY · isDragged · getDragSource · getDraggedNode · getStartDragX · getStartDragY · getTargetDragX · getTargetDragY · effect · removeEffect · clearEffects · hasEffect · getEffect · layer · clearLayers · animate · removeAnimator · wait · watch · hasListener · isVisibleProperty · isMounted · getIndex · getUi · getHierarchy · getMappedIndex · getTaskList · getShortcutList · toJson · toString · getEventBus · getBodyConsumer · getDefaultX · getDefaultY · getLayoutX · getLayoutY · getShiftX · getShiftY · isStepping · getLastCodepoint · getLoadCount · getRenderTime · remove · self · copy · useStore · addTask · removeTask · addShortcut · removeShortcut · layoutPosition · layoutSize · fit · move · beforeMove · hoverColor

EventListenerSummary
onChangeEventListener<NodeChangeEvent.Post<T,Boolean>>Adds a listener that runs after each real change of the state, whatever its source.
Inherited from Node (21)

onUpdate · onDetach · onInit · onRender · onDraw · onMount · onHoverStart · onHover · onHoverEnd · onScroll · onScrollToEnd · onScrollEndReached · onDragStart · onDrag · onDragDrop · onDragSnap · onMove · onChildAppend · onClick · onAnimate · onWatch

BaseToggleNode(double x, double y, double width, double height) protected

Creates the toggle at x, y with a width and a height in design pixels, from the constructor of a skin.

<T> T getValue()

Returns the value that the toggle stands for: the first value of state(...) while it is on, the second one while it is off, or a Boolean without a state.

this state(F toggle, S back) fluent

Gives the two values that getValue() returns, such as "Night" and "Day"; it does not change whether the toggle is on.

<T extends BaseToggleNode<F,S>> T toggle(boolean toggle)

Gives the toggle its start value: true is on; a toggle attached already fires onChange when it differs. A setter is never refused.

<T extends BaseToggleNode<F,S>> T toggle(Signal<Boolean> toggle)

Binds the on state to a signal both ways: the toggle shows the signal, and a press writes the new state into it. Throws an IllegalArgumentException for a signal that cannot be written.

this change(boolean toggle) fluent

Sets the state as if the user pressed the toggle: beforeChange can refuse it, then onChange fires.

<T extends BaseToggleNode<F,S>> T beforeChange(EventListener<NodeChangeEvent.Pre<T,Boolean>> listener)

Adds a listener that runs before a change that a press or change(...) asks for; cancel() refuses it.

boolean isToggle()

If true, the toggle is on.

ToggleState<F,S> getState()

Returns the pair given to state(...), or null before it.

void mousePressed(NodeMouseEvent<?> event) hook

Switches the state on a left press over the toggle that no one consumed, and consumes the press.

<T extends BaseToggleNode<F,S>> T onChange(EventListener<NodeChangeEvent.Post<T,Boolean>> listener)

Adds a listener that runs after each real change of the state, whatever its source.


fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses

Report a problem with this page