Skip to content

Instantly share code, notes, and snippets.

@daveray
Created March 20, 2012 21:20
Show Gist options
  • Save daveray/2141407 to your computer and use it in GitHub Desktop.
Save daveray/2141407 to your computer and use it in GitHub Desktop.
List box model binding example
; very basic example of driving a listbox with binding in Seesaw
(use 'seesaw.core)
(require '[seesaw.bind :as b])
; create a text box and a listbox next to each other
(defn make-ui []
(frame
:size [400 :by 400]
:content (left-right-split
(scrollable (text :id :text :multi-line? true))
(scrollable (listbox :id :list))
:divider-location 1/2)))
(defn add-behaviors [root]
(b/bind
; whenever the text box is changed
(select root [:#text])
; split the text on commas
(b/transform (fn [s] (seq (.split s "\\s*,\\s*"))))
; and show the resulting sequence in the listbox
(b/property (select root [:#list]) :model))
root)
(invoke-later
(-> (make-ui)
add-behaviors
show!))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment