2

Can anyone please help me understanding, what is going on in this piece of code:

(defn- make-edit-mode-container [widget]
  (let [input-container (template/node [:input.editable-edit-mode {:type "text"}])
        ghandler (goog.events.KeyHandler. input-container)]
      (set! (. input-container -gEditableHandler) ghandler)
  ;; ...
  ;; ...
  input-container))

As I understand, here a private function is declared, it accepts a widget parameter. The local-scope variable input-container is a node (actually it is a dommy.template node) which is a HTML <input type="text" class="editable-edit-mode"> element.

What I can't undestand is (goog.events.KeyHandler. input-container) (e.g. what is dot doing at the end of goog.events.Keyhandler).

Consequently, AFAIU (. input-container -gEditableHandler) is a member access, but then where -gEditableHandler comes from and what does the dash mean?

Thanks in advance.

1 Answer 1

8

(goog.events.KeyHandler. input-container) is calling the KeyHandler as constructor hence it is equals to this js code : new goog.events.KeyHandler(input-container);

(. input-container -gEditableHandler) is accessing the property gEditableHandler of input-container, the - before gEditableHandler indicate to the compiler that it is a property access and not a method call (as method call also have same syntax i.e (. obj method))

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.