on-input added, on-create/setup before other events

This commit is contained in:
David Botton 2022-07-17 16:11:24 -04:00
parent 6bf8860b94
commit f9143f9111
6 changed files with 54 additions and 47 deletions

View file

@ -10,14 +10,14 @@
:properties nil)
`(;; unique name to control used to identify it the .clog xml
:name "<%= (@ sys-name) %>"
;; how control appears in builder control list
;; how control appears in builder control list
:description "<%= (@ sys-name) %>"
;; the common lisp type of the control
:clog-type <%= (@ sys-name) %>:<%= (@ sys-name) %>-element
;; the create-function used to create the function
;; at _design time_ at run time only clog:attach-as-child is used
;; any initialization at _run time_ is done with :on-setup below.
:create <%= (@ sys-name) %>:create-<%= (@ sys-name) %>-design
:create <%= (@ sys-name) %>:create-<%= (@ sys-name) %>-element
;; clog has the following create-types
;; :base - create
;; :element - create create-content
@ -30,23 +30,30 @@
:setup ,(lambda (control content control-record)
(declare (ignore content) (ignore control-record))
;; default custom attribute values and events at design time
;; tell the builder this is a composite control, ie made of multiple
;; controls
;; (setf (attribute control "data-clog-composite-control") "t")
)
;; code to run at _run time_ after all controls attached to panel
:on-setup ,(lambda (control control-record)
(setf (attribute control "data-clog-composite-control") "t"))
;; code to run at _run time_ after all controls attached to panel
:on-setup ,(lambda (control control-record)
(declare (ignore control control-record))
;; initialization at run time and apply custom attributes
(format nil "(<%= (@ sys-name) %>:attach-<%= (@ sys-name) %> target)"))
;; code to run at _design time_ on load from .clog file or paste
;; :on-load ,(lambda (control control-record)
;; (declare (ignore control-record))
;; ;; code to attach functionality if your create for design time
;; initialization at run time and apply custom attributes
(format nil "(<%= (@ sys-name) %>:attach-<%= (@ sys-name) %> target)"))
;; code to run at _design time_ on load from .clog file or paste
;; :on-load ,(lambda (control control-record)
;; (declare (ignore control-record))
;; ;; code to attach functionality if your create for design time
;; )
;; events handled
:events (,@clog-tools::*events-element*)
;; properties handled
:properties (,@clog-tools::*props-element*))))
:properties (,@clog-tools::*props-location*
,@clog-tools::*props-with-height*
,@clog-tools::*props-text*
,@clog-tools::*props-css*
,@clog-tools::*props-colors*
,@clog-tools::*props-display*
,@clog-tools::*props-flex-item*
,@clog-tools::*props-nav*
,@clog-tools::*props-contents*))))
(format t "~%<%= (@ SYS-NAME) %> installed in CLOG Builder"))

View file

@ -25,33 +25,15 @@
(class nil)
(html-id nil)
(auto-place t))
"Not used by builder, but used to create in non-builder code"
"Create control - used at design time and in code"
(let ((new-obj (create-div obj
:class class
:hidden hidden
:html-id html-id
:auto-place auto-place)))
(set-geometry new-obj :width 200 :height 100)
(change-class new-obj '<%= (@ sys-name) %>-element)
(attach-<%= (@ sys-name) %> new-obj)
(change-class new-obj '<%= (@ sys-name) %>-element)))
(defgeneric create-<%= (@ sys-name) %>-design (clog-obj &key hidden class html-id auto-place)
(:documentation "Create a new <%= (@ sys-name) %>-element as child of CLOG-OBJ to display
in builder representing <%= (@ sys-name) %> at design time."))
(defmethod create-<%= (@ sys-name) %>-design ((obj clog:clog-obj)
&key
(hidden nil)
(class nil)
(html-id nil)
(auto-place t))
(let ((new-obj (create-div obj
:class class
:hidden hidden
:html-id html-id
:auto-place auto-place)))
(set-geometry new-obj :width 200 :height 100)
(setf (background-color new-obj) :black)
new-obj))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -73,16 +55,20 @@ in builder representing <%= (@ sys-name) %> at design time."))
;; Implementation - js binding
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun init-<%= (@ sys-name) %> (obj)
(defgeneric init-<%= (@ sys-name) %> (<%= (@ sys-name) %>-element)
(:documentation "Initialize libraries"))
(defmethod init-<%= (@ sys-name) %> ((obj <%= (@ sys-name) %>-element))
(check-type obj clog:clog-obj)
;; Only init once
;; use load-css for any css files to load
;; ise load-script for any js files to load
)
(defgeneric attach-<%= (@ sys-name) %> (<%= (@ sys-name) %>-element)
(:documentation "Initialize plugin"))
(defun attach-<%= (@ sys-name) %> (obj)
"Initialize plugin"
(defmethod attach-<%= (@ sys-name) %> ((obj <%= (@ sys-name) %>-element))
(init-<%= (@ sys-name) %> obj))
(defun on-test-<%= (@ sys-name) %> (body)
@ -92,10 +78,9 @@ in builder representing <%= (@ sys-name) %> at design time."))
(let* ((layout (create-panel-box-layout body))
(test (create-<%= (@ sys-name) %>-element (center-panel layout))))
(center-children (center-panel layout))))
(defun start-test ()
(initialize 'on-test-<%= (@ sys-name) %>
:static-root (merge-pathnames "./www/"
(asdf:system-source-directory :<%= (@ sys-name) %>)))
(open-browser))