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?
-- Henrik On Sat, Dec 3, 2011 at 4:44 AM, Rett Kent <rett.k...@gmail.com> wrote: > So, I've been dipping my toe in the waters of Clojure UI development using > Gnome, and I immediately ran in into a problem making me regret my years of > Java apathy. I'm trying to write a toy program to processes generic key > presses made to the Gnome window and I'm stuck as to how to translate the > straight forward Java + Gnome interop into Clojure + Gnome Interop. Here > are the relevant pieces: > > > w = new Window(); > l = new Label("<b>Start Typing!</b>\n" + "Start typing and details about\n" > + "your KeyEvents will\n" + "appear on the console."); > l.setUseMarkup(true); > w.add(l); > w.connect(new Widget.KeyPressEvent() { > public boolean onKeyPressEvent(Widget source, EventKey event) { > final Keyval key; > final ModifierType mod; > key = event.getKeyval(); > mod = event.getState(); > System.out.print("Pressed: " + key.toString() + ", "); > System.out.print("Modifier: " + mod.toString() + " "); > if (mod == ModifierType.SHIFT_MASK) { > System.out.print("That's Shifty!"); > } > if (mod.contains(ModifierType.**ALT_MASK)) { > System.out.print("Hooray for Alt!"); > } > if (mod.contains(ModifierType.**SUPER_MASK)) { > System.out.print("You're Super!"); > } > System.out.println(); > return false; > } > }); > > And in Clojure: > > ... > > (let [w (Window.) > > ... > > (.connect w > (proxy [Widget$KeyPressEvent] [] > (onKeyPressEvent [source event] > (println (str "I was clicked: " (.getLabel b))) > )) > (proxy [Window$DeleteEvent] [] > (onDeleteEvent [source event] > (Gtk/mainQuit) false) > (onDeleteEvents [source event] > (Gtk/mainQuit) false) > )) > > ... > > And here's what I'm trying to do with it: > > > (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 "I was clicked: " (.getLabel b))) > )) > (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) > ) > ) > > > Results in: > > Exception in thread "main" java.lang.RuntimeException: > java.lang.**ClassNotFoundException: > org.gnome.gtk.Window$**KeyPressEvents > at clojure.lang.Util.**runtimeException(Util.java:**153) > at clojure.lang.Compiler.eval(**Compiler.java:6417) > at clojure.lang.Compiler.eval(**Compiler.java:6396) > at clojure.lang.Compiler.load(**Compiler.java:6843) > at clojure.lang.Compiler.**loadFile(Compiler.java:6804) > at clojure.main$load_script.**invoke(main.clj:282) > at clojure.main$script_opt.**invoke(main.clj:342) > at clojure.main$main.doInvoke(**main.clj:426) > at clojure.lang.RestFn.invoke(**RestFn.java:408) > at clojure.lang.Var.invoke(Var.**java:401) > at clojure.lang.AFn.**applyToHelper(AFn.java:161) > at clojure.lang.Var.applyTo(Var.**java:518) > at clojure.main.main(main.java:**37) > Caused by: java.lang.**ClassNotFoundException: org.gnome.gtk.Window$** > KeyPressEvents > at java.net.URLClassLoader$1.run(**URLClassLoader.java:217) > at java.security.**AccessController.doPrivileged(**Native Method) > at java.net.URLClassLoader.**findClass(URLClassLoader.java:**205) > at clojure.lang.**DynamicClassLoader.findClass(** > DynamicClassLoader.java:61) > at java.lang.ClassLoader.**loadClass(ClassLoader.java:**321) > at java.lang.ClassLoader.**loadClass(ClassLoader.java:**266) > at java.lang.Class.forName0(**Native Method) > at java.lang.Class.forName(Class.**java:186) > at user$eval21.invoke(main.clj:8) > at clojure.lang.Compiler.eval(**Compiler.java:6406) > > > Any thoughts or suggestions would be appreciated. > > Thanks! > > -- > 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+unsubscribe@**googlegroups.com<clojure%2bunsubscr...@googlegroups.com> > For more options, visit this group at > http://groups.google.com/**group/clojure?hl=en<http://groups.google.com/group/clojure?hl=en> -- 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