diff options
author | scgilardi <scgilardi@gmail.com> | 2009-06-03 00:43:38 +0000 |
---|---|---|
committer | scgilardi <scgilardi@gmail.com> | 2009-06-03 00:43:38 +0000 |
commit | 0bb0b5498538126d6ac2fa4ea8def640ef17f67a (patch) | |
tree | 8dcb8a520461abc90d59aa78a0ecdbd28dc4d6f4 | |
parent | b9676e089b86536b6ce8980d4367140f80694928 (diff) |
swing-utils: return the newly created listeners, patch from Roland Sadowski
-rw-r--r-- | src/clojure/contrib/swing_utils.clj | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/clojure/contrib/swing_utils.clj b/src/clojure/contrib/swing_utils.clj index 2feadf1d..edcec999 100644 --- a/src/clojure/contrib/swing_utils.clj +++ b/src/clojure/contrib/swing_utils.clj @@ -18,15 +18,20 @@ (defn add-action-listener "Adds an ActionLister to component. When the action fires, f will be - invoked with the event as its first argument followed by args" + invoked with the event as its first argument followed by args. + Returns the listener." [component f & args] - (.addActionListener component (proxy [ActionListener] [] - (actionPerformed [event] (apply f event args))))) + (let [listener (proxy [ActionListener] [] + (actionPerformed [event] (apply f event args)))] + (.addActionListener component listener) + listener)) (defn add-key-typed-listener "Adds a KeyListener to component that only responds to KeyTyped events. When a key is typed, f is invoked with the KeyEvent as its first argument - followed by args" + followed by args. Returns the listener." [component f & args] - (.addKeyListener component (proxy [KeyAdapter] [] - (keyTyped [event] (apply f event args))))) + (let [listener (proxy [KeyAdapter] [] + (keyTyped [event] (apply f event args)))] + (.addKeyListener component listener) + listener)) |