I just hit this issue myself and wrote a macro to make it a bit easier to extend google-closure provided classes. Here's the code:
(ns move.macros (:require [cljs.compiler :as compiler] [cljs.core :as cljs])) (defmacro goog-extend [type base-type ctor & methods] `(do (defn ~type ~@ctor) (goog/inherits ~type ~base-type) ~@(map (fn [method] `(set! (.. ~type -prototype ~(to-property (first method))) (fn ~@(rest method)))) methods))) And here's the macro in action. I'm extending TreeControl so that I can intercept when the user presses ENTER on an item in the tree: (ns move.views (:use-macros [move.macros :only [goog-extend]] [cljs.core :only [this-as]]) (goog-extend MyTree goog/ui.tree.TreeControl ([name config] (this-as this (goog/base this name config))) (handleKeyEvent [e] (this-as this (goog/base this "handleKeyEvent" e) (let [view (.-hiddenView this)] (when (#{(.-ENTER goog/events.KeyCodes) (.-MAC_ENTER goog/events.KeyCodes)} (.-keyCode e)) (events/fire [:edit view] (get-selected-index this)) (.preventDefault e)))))) (defn- make-list-view [name] (let [config goog/ui.tree.TreeControl.defaultConfig tree (MyTree. name config)] tree)) On Sunday, July 1, 2012 9:08:27 PM UTC-4, David Nolen wrote: > > On Fri, Jun 29, 2012 at 9:08 AM, Danny O' Connor <dann...@gmail.com> > wrote: > > Hello, > > > > I'm trying to build an user interface in Clojurescript using the Google > > Closure library. > > > > It appears that the idiomatic way to use the goog.ui package is to > create > > subclasses of goog.ui.Component. > > > > Firstly, is this possible in Clojurescript ? This kind of approach > doesn't > > appear to work: > > > > (defrecord EchoComponent [text] > > goog.ui.Component > > (render [] text)) > > That won't work. You'll need to write CLJS that is equivalent to JS > for doing what GClosure expects. > -- 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