Sample code

From HalyardWiki

Jump to: navigation, search

Halyard scripts are written in Scheme. Our object model is based on SmallTalk and Ruby, with full support for Ruby-style metaprogramming (PDF).

For an introduction to our object model, please see Halyard object model tutorial. For details about how metaprogramming works in the object model, and the primitives it is built from, see Halyard object model details.

(define-class %menu-item% (%box%)
  ;; Declare member variables for this class.
  (attr y :type <integer>)
  (attr text :type <string>)
  (attr jump-to)
  
  ;; Pass values to our superclass constructor.
  (value at (point 0 (.y)))
  (value shape (shape 800 100))
  (value clickable-where-transparent? #t)
  
  ;; Declare a child element.  This will get automatically
  ;; created whenever we create a %menu-item%.
  (centered-text label ($menu-style (.text)
                        :max-width (rect-width (.shape))))

  ;; When somebody clicks on this element, jump to the
  ;; specified card.
  (def (mouse-down event)
    (jump (.jump-to))))
Personal tools