Node

abstract class Node

The base class for all GUI elements in a Scene. The nodes form a Scene Graph (which is a misnomer, because it is a tree structure, not a graph), starting at the Scene.root Node.

Each Node may only appear once (i.e. you cannot use the same node in two place, or in two scenes).

See Scene for a Class Diagram.

Inheritors

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The base class Node has no children, so this is an empty list.

Link copied to clipboard
Link copied to clipboard

If a mouse is clicked on a node, should it request the focus? For controls which can be read-only (such as TextArea / TextField), we may want to jump over them when pressing Tab (i.e. focusTraversable = false), but if the are clicked, then they should accept input focus. The user may wish to select, and copy part of the text.

Link copied to clipboard
Link copied to clipboard

true when this node has the input focus. Only 1 node per scene has the input focus.

Link copied to clipboard
Link copied to clipboard

Is this part of the cycle of node that can accept keyboard focus when he user presses the Tab key (or Shift-Tab).

Link copied to clipboard
Link copied to clipboard

On a scale of 0..1, if this Node's parent has extra space compared to its preferred size, how much extra space should be give to this Node relative to its siblings?

Link copied to clipboard

The actual height of this node, in LogicalPixels.

Link copied to clipboard
Link copied to clipboard
var id: String
Link copied to clipboard

Supposedly unique identifier (or blank). However, it is up to the application developer to ensure the id is unique.

Link copied to clipboard

The position of this Node, relative to its parent Node in LogicalPixels. The position and size of Nodes are assigned by their parent in layout, using setChildBounds.

Link copied to clipboard
Link copied to clipboard

The position of this Node, relative to its parent Node in LogicalPixels. The position and size of Nodes are assigned by their parent in layout, using setChildBounds.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var parent: Node?
Link copied to clipboard

Similar to styles, but used for temporary styles, such as :hover.

Link copied to clipboard
var scene: Scene?
Link copied to clipboard

An ObservableOptionalFont, whose value is Theme.defaultFont. To access this is quite convoluted, because both Node.scene and Scene.theme can change.

Link copied to clipboard

The X position of the Node relative to the top left of the window in LogicalPixels. The position and size of Nodes are assigned by their parent in layout, using setChildBounds.

Link copied to clipboard
Link copied to clipboard

The Y position of the Node relative to the top left of the window in LogicalPixels. The position and size of Nodes are assigned by their parent in layout, using setChildBounds.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

On a scale of 0..1, if this Node's parent has extra space compared to its preferred size, how much should this node shrink by compared to its siblings.

Link copied to clipboard

Used by the Theme to determine how this node should be styled. Similar in concept to CSS's class attribute.

Link copied to clipboard
Link copied to clipboard

Defines a popup that appears when the user hover the mouse over this node for a period of time. Typically, containing help text and a KeyCombination.displayText (if this node can be activated using a keyboard shortcut).

Link copied to clipboard
Link copied to clipboard

When false, this node will not appear in the scene, and will not take up any spaces.

Link copied to clipboard

The actual width of this node, in LogicalPixels.

Link copied to clipboard

Functions

Link copied to clipboard
fun <E : Event> addEventFilter(eventType: EventType<E>, handler: EventHandler<E>, combination: HandlerCombination = HandlerCombination.AFTER)
fun <E : Event> addEventFilter(eventType: EventType<E>, handlerCombination: HandlerCombination = HandlerCombination.AFTER, handler: (E) -> Unit)
Link copied to clipboard
fun <E : Event> addEventHandler(eventType: EventType<E>, handler: EventHandler<E>, combination: HandlerCombination = HandlerCombination.AFTER)

fun <E : Event> addEventHandler(eventType: EventType<E>, combination: HandlerCombination = HandlerCombination.AFTER, handler: (E) -> Unit)
Link copied to clipboard
fun containsScenePoint(sceneX: Float, sceneY: Float): Boolean
Link copied to clipboard
fun dump(prefix: String = "", borders: Boolean = true, size: Boolean = true, filter: (Node) -> Boolean = { it.visible })

Dumps the scene graph to stdout starting at this Node, and walking through all descendants. Useful for debugging, and to give insights into the structure of controls.

Link copied to clipboard

Converts em units to LogicalPixels.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun findDeepestNodeAt(sceneX: Float, sceneY: Float): Node

@return this if none of my children are at sceneX,sceneY. Otherwise, the child (or one of its ancestors).

Link copied to clipboard

Checks this node, and all descendants for a matching id. @return The first node which matches, or null if none match.

Link copied to clipboard
fun firstToRoot(filter: (Node) -> Boolean): Node?

Tests each node from this one to the root node. When filter hold true, that node is returned, stopping the iteration. If none are found, returns null.

Link copied to clipboard
fun forEachDescending(block: (Node) -> Unit)
Link copied to clipboard
fun forEachFromRoot(block: (Node) -> Unit)

Applies a block of code on this node, and all of its ancestors, starting at the root node and working downwards to this node.

Link copied to clipboard
fun forEachToRoot(block: (Node) -> Unit)

Applies a block of code on this node, and all of its ancestors, starting at this node and working up to the root node.

Link copied to clipboard
Link copied to clipboard

Return true, if other === this, or this is a parent, grandparent etc. of other.

Link copied to clipboard
Link copied to clipboard
open fun nodeMaxHeight(): Float

The default implementation returns NO_MAXIMUM (an arbitrary large number : 100,000).

Link copied to clipboard
open fun nodeMaxWidth(): Float

The default implementation returns NO_MAXIMUM (an arbitrary large number : 100,000).

Link copied to clipboard
open fun nodeMinHeight(): Float

Each subclass of node can determine the minimum width it requires. This can be overridden on an ad-hoc basis using overrideMinHeight. The default implementation returns 0.

Link copied to clipboard
open fun nodeMinWidth(): Float

Each subclass of node can determine the minimum width it requires. This can be overridden on an ad-hoc basis using overrideMinWidth. The default implementation returns 0.

Link copied to clipboard
abstract fun nodePrefHeight(): Float

Each subclass of node can determine its preferred height. As most nodes are composed of smaller nodes, this is typically calculated using evalPrefWidth of the child nodes, with extra added for spacing, padding and borders.

Link copied to clipboard
abstract fun nodePrefWidth(): Float

Each subclass of node can determine its preferred width. As most nodes are composed of smaller nodes, this is typically calculated using evalPrefWidth of the child nodes, with extra added for spacing, padding and borders.

Link copied to clipboard
fun onKeyPressed(combination: HandlerCombination = HandlerCombination.AFTER, handler: (KeyEvent) -> Unit)

A more convenient version of addEventHandler for EventType.KEY_PRESSED.

Link copied to clipboard
fun onKeyReleased(combination: HandlerCombination = HandlerCombination.AFTER, handler: (KeyEvent) -> Unit)

A more convenient version of addEventHandler for EventType.KEY_RELEASED.

Link copied to clipboard
fun onKeyTyped(combination: HandlerCombination = HandlerCombination.AFTER, handler: (KeyTypedEvent) -> Unit)

A more convenient version of addEventHandler for EventType.KEY_TYPED.

Link copied to clipboard
fun onMouseClicked(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_CLICKED.

Link copied to clipboard
fun onMouseDragged(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_DRAGGED.

Link copied to clipboard
fun onMouseEntered(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_ENTERED.

Link copied to clipboard
fun onMouseExited(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_EXITED.

Link copied to clipboard
fun onMouseMoved(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_MOVED.

Link copied to clipboard
fun onMousePressed(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_PRESSED.

Link copied to clipboard
fun onMouseReleased(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

A more convenient version of addEventHandler for EventType.MOUSE_RELEASED.

Link copied to clipboard
fun onPopupTrigger(combination: HandlerCombination = HandlerCombination.AFTER, handler: (MouseEvent) -> Unit)

handler will fire when the secondary mouse button is pressed/released depending on the platform.

Link copied to clipboard
fun onScrolled(combination: HandlerCombination = HandlerCombination.AFTER, handler: (ScrollEvent) -> Unit)

A more convenient version of addEventHandler for EventType.SCROLL.

Link copied to clipboard
Link copied to clipboard

Adds a style to Node.pseudoStyle

Link copied to clipboard
fun Node.pseudoStyleIf(test: Boolean, pseudoStyle: String)

Adds or removes the pseudoStyle depending on test. See Node.pseudoStyles

fun Node.pseudoStyleIf(test: Boolean, trueStyle: String, falseStyle: String)

When test is true, trueStyle is added, and falseStyle is removed from Node.pseudoStyles.

Link copied to clipboard
fun <E : Event> removeEventFilter(eventType: EventType<E>, handler: EventHandler<E>)
Link copied to clipboard
fun <E : Event> removeEventHandler(eventType: EventType<E>, handler: EventHandler<E>)
Link copied to clipboard
fun requestFocus(useFocusTraversable: Boolean = false)
Link copied to clipboard
open fun requestLayout()

Informs all ancestors that the pref/min/max size of this node has changed, and therefore layoutChildren needs to be called again before the scene is rendered. Cached data, such as prefWidth/height should be invalidated.

Link copied to clipboard

Informs that this node needs to be redrawn. Currently, this causes the whole scene to be redrawn.

Link copied to clipboard
Link copied to clipboard
fun Node.style(name: String)

Adds a style to Node.styles

Link copied to clipboard
fun Node.styleIf(test: Boolean, style: String)

Adds or removes the style depending on test. See Node.styles

Link copied to clipboard
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
fun treeVisitor(filter: (Node) -> Boolean = { true }, action: (Node) -> Unit)

Visits this node, and all descendant nodes, performing an action on each. Each node is filtered. If filter returns false, action will not be called on that node, and its children will not be visited.

Link copied to clipboard