Finder
This component search an element among the children of a Container (i.e. a Component
or a List
) according to the value of the specified property.
Constructor
Finder <id> (Process container, string path_and_name_of_the_property)
Action
Search for an element each time the value of the key is updated.Predefined children
- TextProperty:
path
path and name of the property over which the search is made. - TextProperty:
key
value of the key that is searched. - Spike:
found
triggered if an element has been found. - Spike:
notFound
triggered if no element has been found. - RefProperty:
result
reference toward the element found if any.
Example
use core
use base
use gui
_main_
Component root {
Frame f ("my frame", 0, 0, 400, 600)
Exit ex (0, 1)
f.close -> ex
FillColor _ (200, 50, 50)
OutlineColor _ (100, 100, 250)
FillOpacity _ (0.5)
List l {
Rectangle r1 (0, 0, 100, 40, 0, 0)
Rectangle r2 (0, 10, 50, 60, 0, 0)
Rectangle r3 (0, 20, 150, 90, 0, 0)
}
Finder finder (l, "width")
AssignmentSequence change (1) {
100 =: finder.key
}
f.press->change
finder.found->(finder) {
r = getRef (&finder.result)
delete r
}
TextPrinter log
AssignmentSequence not_found (1) {
"not found" =: log.input
}
AssignmentSequence found (1) {
"found" =: log.input
}
finder.notFound->not_found
finder.found->found
}