On 12/03/2011 10:16 AM, Henrik Lundahl wrote:
Hi Rett

There is no such type as org.gnome.gtk.Window$__KeyPressEvents, at least
not in 4.1 of the Java Gnome API
<http://java-gnome.sourceforge.net/doc/api/4.1/org/gnome/gtk/Window.html>.  
org.gnome.gtk.Window$__KeyPressEvent
exists though. I'd guess you have a typo somewhere, perhaps in the imports?

Not a terribly auspicious first post for technical assistance, I'm afraid. KeyPressEvents was indeed a typo on my part. The two changes that seemed to make a difference are to change 'KeyPressEvents' to 'KeyPressEvent' and to separate the proxy statements into two connect clauses. I'm not sure why that was necessary, but the following did work.


(import '(org.gnome.gtk Button Button$Clicked Gtk Label VBox Widget Window Window$DeleteEvent Widget$KeyPressEvent))

(Gtk/init (make-array String 0))
;(defonce gtk-init (.init Gtk (make-array String 0)))

(defn pushme []
  (let [w (Window.)
        v (VBox. false 3)
        l (Label. "Go ahead:\nMake my day")
        b (Button. "Press me!")]
    (.connect b
              (proxy [Button$Clicked] []
                (onClicked [source]
                  (println (str "I was clicked: " (.getLabel b)))
                  (println (str "I was clicked: " source))
                  )))
    (.connect w
              (proxy [Widget$KeyPressEvent] []
                (onKeyPressEvent [source event]
(println (str "Key was pressed: " (.toString (.getKeyval event))))
                  false)
                ))

    (.connect w
              (proxy [Window$DeleteEvent] []
                (onDeleteEvent [source event]
                  (Gtk/mainQuit) false)
                (onDeleteEvents [source event]
                  (Gtk/mainQuit) false)
                ))
    (.add v l)
    (.add v b)
    (.add w v)
    (.setDefaultSize w 200 100)
    (.setTitle w "Push Me")
    (.showAll w)
    (Gtk/main)
    )
  )

--
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
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to