mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
more demo of presentations
This commit is contained in:
parent
cbd18532cc
commit
ca2a5c1fdf
1 changed files with 25 additions and 9 deletions
|
|
@ -8,25 +8,41 @@
|
||||||
(in-package :clog-tut-29)
|
(in-package :clog-tut-29)
|
||||||
|
|
||||||
(defclass my-class ()
|
(defclass my-class ()
|
||||||
((my-slot :accessor my-slot :initform "")))
|
((my-slot :accessor my-slot :initform "")
|
||||||
|
(my-count :accessor my-count :initform 500)))
|
||||||
|
|
||||||
(defun on-new-window (body)
|
(defun on-new-window (body)
|
||||||
(let* ((lisp-obj (make-instance 'my-class))
|
(let* ((lisp-obj (make-instance 'my-class))
|
||||||
(l1 (create-label body :content "Form value:"))
|
(i1 (create-form-element body :text
|
||||||
(i1 (create-form-element body :text))
|
:label (create-label body :content "Form value:")))
|
||||||
(l2 (create-label body :content "(my-slot lisp-obj) value:"))
|
(i2 (create-form-element body :text
|
||||||
(i2 (create-form-element body :text))
|
:label (create-label body :content "(my-slot lisp-obj) value:")))
|
||||||
(b1 (create-button body :content "Set (my-slot lisp-obj) Value"))
|
(b1 (create-button body :content "Set (my-slot lisp-obj) Value"))
|
||||||
(b2 (create-button body :content "Get (my-slot lisp-obj) Value")))
|
(b2 (create-button body :content "Get (my-slot lisp-obj) Value"))
|
||||||
(link-form-element-to-slot i1 lisp-obj my-slot)
|
(tmp (create-br body))
|
||||||
(link-slot-to-form-element lisp-obj my-slot i1)
|
(t1 (create-div body :content "[counter]")))
|
||||||
|
;; We set up direct relationships between lisp obj and clog objects
|
||||||
|
(link-form-element-to-slot i1 lisp-obj my-slot) ;; any change to i1 will change my-slot
|
||||||
|
(link-slot-to-form-element lisp-obj my-slot i1) ;; any change to my-slot will change i1
|
||||||
|
(link-slot-to-element lisp-obj my-count t1) ;; any change to my-count will chat t1
|
||||||
|
;; This change of my-slot will immediately change in the web page
|
||||||
(setf (my-slot lisp-obj) "First Value")
|
(setf (my-slot lisp-obj) "First Value")
|
||||||
(set-on-click b1
|
(set-on-click b1
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
|
(declare (ignore obj))
|
||||||
(setf (my-slot lisp-obj) (value i2))))
|
(setf (my-slot lisp-obj) (value i2))))
|
||||||
(set-on-click b2
|
(set-on-click b2
|
||||||
(lambda (obj)
|
(lambda (obj)
|
||||||
(setf (value i2) (my-slot lisp-obj))))))
|
(declare (ignore obj))
|
||||||
|
(setf (value i2) (my-slot lisp-obj))))
|
||||||
|
;; This updates an element on the page by just changing the value of the linked
|
||||||
|
;; slot
|
||||||
|
(loop
|
||||||
|
(cond ((> (my-count lisp-obj) 0)
|
||||||
|
(decf (my-count lisp-obj))
|
||||||
|
(sleep .2))
|
||||||
|
(t
|
||||||
|
(return))))))
|
||||||
|
|
||||||
(defun start-tutorial ()
|
(defun start-tutorial ()
|
||||||
(initialize 'on-new-window)
|
(initialize 'on-new-window)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue