well, it has changed quite a lot now: (i'm not sure if this all actually works yet. they key map does, though)
;;gui imports. hurray! (import '(javax.swing JFrame) '(java.awt Canvas) '(java.awt.event KeyListener KeyEvent MouseListener MouseEcent FocusListener FocusEvent)) (defstruct window :win :canvas :buffer :keys-down :clicks) (defn make-win "makes a window, complete with canvas, backbuffer, key map, and click map. maps are cleared when the window loses appropriate focus." [x y] (let [win (JFrame.) canvas (Canvas.) keys-down (agent {}) clicks (agent {})] (doto canvas (setSize x y) (addKeyListener (proxy [KeyListener] [] (keyTyped [#^KeyEvent e] nil) (keyPressed [#^KeyEvent e] (send keys-down assoc (. e getKeyCode) e)) (keyReleased [#^KeyEvent e] (send keys-down dissoc (. e getKeyCode))))) (addMouseListener (proxy [MouseListener] [] (mousePressed [#^MouseEvent e] (send clicks assoc (. e getButton) e)) (mousereleased [#^MouseEvent e] (send clicks dissoc (. e getButton))) (mouseExited [#^MouseEvent e] (send clicks (fn [a] {}))) (mouseEntered [#^MouseEvent e]) (mouseClicked [#^MouseEvent e]))) (addFocusListener (proxy [FocusListener] [] (FocusGained [#^FocusEvent e]) (FocusLost [#^FocusEvent e] (send keys-down (fn [a] {})))))) (doto win (setIgnoreRepaint true) (setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (add canvas) (pack) (setVisible true)) (doto canvas (createBufferStrategy 2)) (struct window win canvas (. canvas getBufferStrategy) keys-down clicks))) i think this is what i had when i first got it working error-free, though: (this works, i just don't know for sure if it's what i had) (import '(javax.swing JFrame) '(java.awt Canvas) '(java.awt.event KeyListener KeyEvent)) (def app (JFrame.)) (def canvas (proxy [Canvas KeyListener] [] (keyPressed [e] (println "hay! it's working!")) (keyReleased [e] (println "released")) (keyTyped [e] (println "typed")))) (doto canvas (setFocusable true) (addKeyListener canvas)) (doto app (add canvas) (setDefaultCloseOperation JFrame/EXIT_ON_CLOSE) (setSize 640 480) (setVisible true)) without the keyReleased and keyTyped, it throws a bunch of errors. in between the errors, it was printing stuff, though. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~----------~----~----~----~------~----~------~--~---