0

I have a nine textboxes nested inside of vertical panels that I want grab the text from and use. For convenience, I'm just using select to grab them by class, then applying them to the constructor of a record. Basically something like:

(ns example.core
    (:require [seesaw.core :as sc]))

(apply ->RecordConstructor
       (sc/select root [:.textbox]))

This seems to work as I expect, but I haven't been able to find anything official on what defines the order that select returns its elements in.

It seems to be based on the order that the elements were given to their parent. Is this correct?

Carcigenicate
  • 43,494
  • 9
  • 68
  • 117
  • What is the `sc` namespace? – Alan Thompson Nov 15 '17 at 20:14
  • @AlanThompson Whoops. That's my alias for the seesaw core. I'll just remove it since the question is tagged with seesaw. – Carcigenicate Nov 15 '17 at 20:16
  • Personally I'd vastly prefer if you instead put a `(ns foo.core (:require [seesaw.core :as sc]))` or `(require '[,,, :as sc])` before the snippet. Clojure core has hundreds of vars and it can be hard to know what's coming from where. Especially in a snippet here on this site, outside of a codebase where you have a shared context. (Even inside of a codebase I prefer to (almost) never :refer or :use anything, but what you do behind closed doors is between you and the people you work with.) Just my 2c. – madstap Nov 17 '17 at 15:07
  • 1
    @madstap Fixed. – Carcigenicate Nov 17 '17 at 15:46

1 Answers1

2

I'm no expert, but it looks like seesaw just does a depth-first tree walk of its document model. So there's nothing guaranteed, but sure, it sounds like you will get things in that order: depth-first, leftmost-first. Here "left" is whatever order seesaw stores its stuff in, not necessarily display order. Again I don't know what order that is, but your guess of "the order you added stuff to the model" seems as good as any to me.

amalloy
  • 89,153
  • 8
  • 140
  • 205