Separate handlers = brilliant! I have no idea why I never thought of it. On Monday, February 10, 2014 3:00:37 PM UTC-8, Dave Sann wrote: > On Monday, 10 February 2014 12:04:07 UTC+11, [email protected] wrote: > > Hi, > > > > I am using cljs + google closure. > > > > I am dealing with keyboard events. > > > > I have a nested SVG as follows: > > > > <svg desktop ... > > > ... > > <svg window ... > > > </svg window > > > ... > > </svg desktop > > > > > The outer svg element represents the desktop. The inner svg element > > represents a window. > > > > > > Now, I am dealing with keyboard inputs -- some of which I want to hit the > > window, and some of which I hit the desktop. > > > > For example, [:keypress :a] [:keypress :b] ==> svg window > > [:keypress :Alt :F4] ==> svg desktop > > > > > > To do this, I'd like to be able to, for a keyboard event, distinguish > > whether it's being hit during the _capture_ (outward in, i.e. desktop => > > window) or during the _bubble_ (inward out, i..e window => desktop) phases. > > > > Thus, my question -- during an event handler, is there a way to figure > > out if the event being processed is from the capture phase or the bubble > > phase? > > > > Thanks! > > To get the event during capture you will need to specify a flag to the google > listen function. > > I don't know if there is a flag on the event itself to say what stage it is > at - I doubt it. > > If you want to use the same handler for capture and bubble you can pass in > the flag to the handler. For example > > (defn handler [capture? evt] ...) > (def capture-handler (partial handler true)) > (def bubble-handler (partial handler false)) > > and then (listen ... capture-handler ...) for the capture stage. > > D
-- Note that posts from new members are moderated - please be patient with your first post. --- You received this message because you are subscribed to the Google Groups "ClojureScript" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/clojurescript.
