-
Notifications
You must be signed in to change notification settings - Fork 149
Selectors
I hope to one day support general CSS-style selectors for finding and styling widgets in an app. The (select)
function supports locating a widget by :id
as set at creation time:
(button :id :the-button :text "Push me")
... later ...
(listen (select root [:#the-button])
:action (fn [e] ... do something ...))
Note that the first argument to (select)
is always the root of the widget hierarchy to search from and the second argument is always a vector containing the selector. I wish the root wasn't necessary, but not requiring it makes it very difficult to support multiple instances of the same frame in one app. Suggestions welcome.
The "all" selector is also supported which will match everything in a sub-tree including the root. For example to disable an entire sub-tree:
(config! (select my-panel [:*]) :enabled? false)
At the moment, I'm planning on following the selector conventions established by [Enlive] (https://github.com/cgrand/enlive). See also, the apparently defunct [Java CSS] (http://weblogs.java.net/blog/2008/07/17/introducing-java-css) project to get an idea where this may lead.
Of all the areas of Seesaw, I think this is the least stable. You may be best off just binding widgets to variables and passing them around.