Introduces node ids as requested in #2. Every Node can now be assigned a String id. This id can be unique, although this uniqueness is not enforced.
To find a node, Node#lookup(String selector) can be used, which looks for the first node matching the selector. Note that in order to find a node by its id, the id has to be prefixed with a hashtag (#).
To retrieve a set of all Nodes matching the selector Node#lookupAll(String selector) can be used.
For convenience, these methods also exist in the Scene class, where they are identical to calling them on the scene root.
The prefix is technically not needed, but was still implemented so that selectors can be expanded in the future to not just be limited to ids.
Code Example
// Assign an id:
node.setId("my-id");
// Lookup by an id:
Node result = scene.lookup("#my-id");
// Lookup all nodes with the id:
Set<Node> results = scene.lookupAll("#my-id");
Description
Introduces node ids as requested in #2. Every
Node
can now be assigned a String id. This id can be unique, although this uniqueness is not enforced. To find a node,Node#lookup(String selector)
can be used, which looks for the first node matching the selector. Note that in order to find a node by its id, the id has to be prefixed with a hashtag (#
). To retrieve a set of allNode
s matching the selectorNode#lookupAll(String selector)
can be used. For convenience, these methods also exist in theScene
class, where they are identical to calling them on the scene root.The prefix is technically not needed, but was still implemented so that selectors can be expanded in the future to not just be limited to ids.
Code Example