ListView
Displays a list of items vertically inside a ScrollPane.
Each visible item in the list is displayed using a ListCell. By default, cellFactory creates TextListCells, whose text is each items value converted to a string using Any.toString. However, you can create a custom cellFactory, which creates any ListCells containing whatever you need.
There are only ever enough ListCells for the visible items. For example, if items.size
== 100, but only 10 fit within the ListView's bounds, then there be 10 ListCells, and as you scroll, the same 10 ListCells will be reused, and their contents will be updated to reflect the data within the items.
If type T is mutable, then the cellFactory must bind
to the item's properties, to ensure that mutating the data is reflected in the ListCell.
Currently, all cells must be the same height, which is governed by fixedRowHeight. and if this is <= 0, then the first cell's prefHeight
is used instead.
Theme DSL
"list_view" {
"fixedCellSize"( float )
descendant("list_cell") {
":odd" { ... }
":even" { ... }
// The selected row of the listView.
":selected" { ... }
}
}
Properties
When set, items in the ListView can be reordered by dragging with the mouse, and also using Ctrl+Up / Down. The default value is false
.
The base class Node has no children, so this is an empty list.
Glok currently assumes that all rows are the same height. The easiest way to do this is settings fixedRowHeight. The default value is 0, in which case Glok looks at the size of the first visible row, and assumes the same is true for all the others. If this assumption is wrong, then scrolling will go wrong (it will jump weirdly).
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 they are clicked, then they should accept input focus. The user may wish to select, and copy part of the text.
The focus border is only ever drawn when the focus is set using keyboard shortcuts. So, when you use TAB or Shift+TAB, the extra focusBorder is drawn, but otherwise, it isn't drawn. This gives an uncluttered most of the time (when TAB isn't used).
true
when this node has the input focus. Only 1 node has the input focus.
A Background, which is drawn ON TOP of the node to highlight it. Used to highlight a section, when using the F6
and Shift+F6
keyboard shortcuts.
Is this part of the cycle of node that can accept keyboard focus when he user presses the Tab
key (or Shift-Tab
).
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?
The actual height of this node, in LogicalPixels.
Supposedly unique identifier (or blank). However, it is up to the application developer to ensure the id is unique.
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.
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.
A simple way to override the value calculated by nodeMinHeight. Most of the time, this value is null
, and therefore nodeMinHeight is used.
A simple way to override the value calculated by nodeMinWidth. Most of the time, this value is null
, and therefore nodeMinWidth is used.
A simple way to override the value calculated by nodePrefHeight. Most of the time, this value is null
, and therefore nodePrefHeight is used.
A simple way to override the value calculated by nodeMinWidth. Most of the time, this value is null
, and therefore nodeMinWidth is used.
Similar to styles, but used for temporary styles, such as :hover
.
An ObservableOptionalFont, whose value is Theme.defaultFont. To access this is quite convoluted, because both Node.scene and Scene.theme can change.
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.
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.
To help navigating a scene using keyboard shortcuts (not using a mouse), it is helpful to jump to different sections of the scene. The keyboard shortcut F6
is similar to TAB
, but instead of moving one Node at a time, it jumps to the next node, where this is true
. Shift+F6
navigates in the opposite direction.
On a scale of 0..1, if this Node's parent has less space compared to its preferred size, how much should this node shrink by compared to its siblings.
Used by the Theme to determine how this node should be styled. Similar in concept to CSS's class
attribute.
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).
When false
, this node will not appear in the scene, and will not take up any spaces.
The actual width of this node, in LogicalPixels.
Functions
Consider using these convenience functions instead : onMousePressed, onMouseReleased, onPopupTrigger, onMouseClicked, onMouseDragged, onMouseMoved, onMouseEntered, onMouseExited, onKeyPressed, onKeyReleased.
Sets Region.borderSize.
Converts em
units to LogicalPixels.
If overrideMaxHeight is set, then return that, otherwise return nodeMaxHeight. Caching is used to improve speed, as calculating sizes can be relatively expensive.
If overrideMaxWidth is set, then return that, otherwise return nodeMaxWidth. Caching is used to improve speed, as calculating sizes can be relatively expensive.
If overrideMinWidth is set, then return that, otherwise return nodeMinHeight. Caching is used to improve speed, as calculating sizes can be relatively expensive.
If overrideMinWidth is set, then return that, otherwise return nodeMinWidth. Caching is used to improve speed, as calculating sizes can be relatively expensive.
If overridePrefWidth is set, then return that, otherwise return nodePrefHeight. Caching is used to improve speed, as calculating sizes can be relatively expensive.
If overridePrefWidth is set, then return that, otherwise return nodePrefWidth. Caching is used to improve speed, as calculating sizes can be relatively expensive.
@return this
if none of my children are at sceneX,sceneY. Otherwise, the child (or one of its ancestors).
Checks this node, and all descendants for a matching id. @return The first node which matches, or null if none match.
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.
Applies a block of code on this node, and all of its ancestors, starting at the root node and working downwards to this node.
Applies a block of code on this node, and all of its ancestors, starting at this node and working up to the root node.
Find the index of value
within items, using ===
as the test. This is different from List.indexOf, which uses equals()
rather than ===
. Therefore List.indexOf would find the wrong item if there are more than one item in the list that met the equals()
test.
Sets [Region.background to NoBackground
The default implementation returns NO_MAXIMUM (an arbitrary large number : 100,000).
The default implementation returns NO_MAXIMUM (an arbitrary large number : 100,000).
Each subclass should override this, to calculate the minimum height it requires. In general, do not call this, and instead call evalMinHeight.
Each subclass should override this to calculate the minimum width it requires. In general, do not call this, and instead call evalMinWidth.
By default, ListViews have an arbitrary prefHeight. Set evalPrefHeight, or add the ListView to a layout control which will allocate a sensible area regardless of evalPrefWidth.
By default, ListViews have an arbitrary prefWidth. Set evalPrefWidth, or add the ListView to a layout control which will allocate a sensible area regardless of evalPrefWidth.
A more convenient version of addEventHandler for EventType.FILES_DROPPED.
A more convenient version of addEventHandler for EventType.KEY_PRESSED.
A more convenient version of addEventHandler for EventType.KEY_RELEASED.
A more convenient version of addEventHandler for EventType.KEY_TYPED.
A more convenient version of addEventHandler for EventType.MOUSE_CLICKED.
A more convenient version of addEventHandler for EventType.MOUSE_DRAGGED.
A more convenient version of addEventHandler for EventType.MOUSE_ENTERED.
A more convenient version of addEventHandler for EventType.MOUSE_EXITED.
A more convenient version of addEventHandler for EventType.MOUSE_MOVED.
A more convenient version of addEventHandler for EventType.MOUSE_PRESSED.
A more convenient version of addEventHandler for EventType.MOUSE_RELEASED.
handler will fire when the secondary mouse button is pressed/released depending on the platform.
A more convenient version of addEventHandler for EventType.SCROLL.
Sets Region.background to Color[color]
Sets Region.background to PlainBackground
Adds a style to Node.pseudoStyle
Adds or removes the pseudoStyle depending on test. See Node.pseudoStyles
When test is true
, trueStyle is added, and falseStyle is removed from Node.pseudoStyles.
Gives the input focus to this node, so that keyboard events are sent to it.
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.
Informs that this node needs to be redrawn. Currently, this causes the whole scene to be redrawn.
Ensure that this node is visible, by asking all ancestor nodes, which are Scrollable, to scroll to this node. ScrollPanes will adjust their scroll bars, TabPanes will select the appropriate tab, TitledPanes will open their content etc.
Adds a style to Node.styles
Adds a thin bar below this node. Dragging the bar changes the Node.overridePrefHeight of the node, therefore the node grows/shrinks.