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

@ -614,6 +614,17 @@ is nil unbind the event."))
(defmethod set-on-change ((obj clog-obj) handler) (defmethod set-on-change ((obj clog-obj) handler)
(set-on-event obj "change" handler)) (set-on-event obj "change" handler))
;;;;;;;;;;;;;;;;;;
;; set-on-input ;;
;;;;;;;;;;;;;;;;;;
(defgeneric set-on-input (clog-obj on-input-handler)
(:documentation "Set the ON-INPUT-HANDLER for CLOG-OBJ. If ON-INPUT-HANDLER
is nil unbind the event."))
(defmethod set-on-input ((obj clog-obj) handler)
(set-on-event obj "input" handler))
;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;
;; set-on-drag-start ;; ;; set-on-drag-start ;;
;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;

View file

@ -137,6 +137,7 @@ embedded in a native template application.)"
(set-on-focus generic-function) (set-on-focus generic-function)
(set-on-blur generic-function) (set-on-blur generic-function)
(set-on-change generic-function) (set-on-change generic-function)
(set-on-input generic-function)
(set-on-drag-start generic-function) (set-on-drag-start generic-function)
(set-on-drag generic-function) (set-on-drag generic-function)
(set-on-drag-end generic-function) (set-on-drag-end generic-function)

View file

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

View file

@ -25,33 +25,15 @@
(class nil) (class nil)
(html-id nil) (html-id nil)
(auto-place t)) (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 (let ((new-obj (create-div obj
:class class :class class
:hidden hidden :hidden hidden
:html-id html-id :html-id html-id
:auto-place auto-place))) :auto-place auto-place)))
(set-geometry new-obj :width 200 :height 100) (set-geometry new-obj :width 200 :height 100)
(change-class new-obj '<%= (@ sys-name) %>-element)
(attach-<%= (@ sys-name) %> new-obj) (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)) new-obj))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@ -73,16 +55,20 @@ in builder representing <%= (@ sys-name) %> at design time."))
;; Implementation - js binding ;; 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) (check-type obj clog:clog-obj)
;; Only init once ;; Only init once
;; use load-css for any css files to load ;; use load-css for any css files to load
;; ise load-script for any js 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) (defmethod attach-<%= (@ sys-name) %> ((obj <%= (@ sys-name) %>-element))
"Initialize plugin"
(init-<%= (@ sys-name) %> obj)) (init-<%= (@ sys-name) %> obj))
(defun on-test-<%= (@ sys-name) %> (body) (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)) (let* ((layout (create-panel-box-layout body))
(test (create-<%= (@ sys-name) %>-element (center-panel layout)))) (test (create-<%= (@ sys-name) %>-element (center-panel layout))))
(center-children (center-panel layout)))) (center-children (center-panel layout))))
(defun start-test () (defun start-test ()
(initialize 'on-test-<%= (@ sys-name) %> (initialize 'on-test-<%= (@ sys-name) %>
:static-root (merge-pathnames "./www/" :static-root (merge-pathnames "./www/"
(asdf:system-source-directory :<%= (@ sys-name) %>))) (asdf:system-source-directory :<%= (@ sys-name) %>)))
(open-browser)) (open-browser))

View file

@ -741,6 +741,8 @@
:parameters "target") :parameters "target")
(:name "on-change" (:name "on-change"
:parameters "target") :parameters "target")
(:name "on-input"
:parameters "target")
(:name "on-focus-in" (:name "on-focus-in"
:parameters "target") :parameters "target")
(:name "on-focus-out" (:name "on-focus-out"

View file

@ -651,7 +651,7 @@ not a temporary attached one when using select-control."
(package (attribute content "data-in-package")) (package (attribute content "data-in-package"))
(slots (attribute content "data-custom-slots")) (slots (attribute content "data-custom-slots"))
(cname (attribute content "data-clog-name")) (cname (attribute content "data-clog-name"))
cmembers vars events) cmembers vars creates events)
(unless (or (equal slots "") (unless (or (equal slots "")
(equal slots "undefined")) (equal slots "undefined"))
(push slots cmembers)) (push slots cmembers))
@ -720,7 +720,7 @@ not a temporary attached one when using select-control."
~A\)~%" ~A\)~%"
vname vname
handler) handler)
events))))) creates)))))
(add-siblings (first-child control))) (add-siblings (first-child control)))
(setf control (next-sibling control)))))) (setf control (next-sibling control))))))
(add-siblings (first-child content))) (add-siblings (first-child content)))
@ -731,7 +731,7 @@ not a temporary attached one when using select-control."
\(defun create-~A \(clog-obj &key \(hidden nil\) \(class nil\) \(html-id nil\) \(auto-place t\)\) \(defun create-~A \(clog-obj &key \(hidden nil\) \(class nil\) \(html-id nil\) \(auto-place t\)\)
\(let \(\(panel \(change-class \(clog:create-div clog-obj :content \"~A\" \(let \(\(panel \(change-class \(clog:create-div clog-obj :content \"~A\"
:hidden hidden :class class :html-id html-id :auto-place auto-place\) \'~A\)\)\) :hidden hidden :class class :html-id html-id :auto-place auto-place\) \'~A\)\)\)
~{~A~}~{~A~} panel\)\)~%" ~{~A~}~{~A~}~{~A~} panel\)\)~%"
(string-upcase package) (string-upcase package)
cname ;;defclass cname ;;defclass
cmembers cmembers
@ -751,7 +751,8 @@ not a temporary attached one when using select-control."
"\\\"") "\\\"")
cname cname
vars vars
(reverse events)))) ; Insure that on-setup/on-create follow order in tree (reverse creates) ; Insure that on-setup/on-create follow order in tree
(reverse events))))
(maphash (lambda (html-id control) (maphash (lambda (html-id control)
(declare (ignore html-id)) (declare (ignore html-id))
(place-after control (get-placer control))) (place-after control (get-placer control)))
@ -2015,13 +2016,13 @@ of controls and double click to select control."
(create-gui-menu-item file :content "New CLOG-WEB Delay Launch" :on-click 'on-new-builder-launch-page) (create-gui-menu-item file :content "New CLOG-WEB Delay Launch" :on-click 'on-new-builder-launch-page)
(create-gui-menu-item file :content "New Custom Boot Page" :on-click 'on-new-builder-custom) (create-gui-menu-item file :content "New Custom Boot Page" :on-click 'on-new-builder-custom)
(create-gui-menu-item file :content "New Application Template" :on-click 'on-new-app-template) (create-gui-menu-item file :content "New Application Template" :on-click 'on-new-app-template)
(create-gui-menu-item file :content "Launch DB Admin" :on-click
(lambda (obj)
(declare (ignore obj))
(open-window (window body) "/dbadmin")))
(create-gui-menu-item tools :content "Control Events" :on-click 'on-show-control-events-win) (create-gui-menu-item tools :content "Control Events" :on-click 'on-show-control-events-win)
(create-gui-menu-item tools :content "Copy/Cut History" :on-click 'on-show-copy-history-win) (create-gui-menu-item tools :content "Copy/Cut History" :on-click 'on-show-copy-history-win)
(create-gui-menu-item tools :content "Image to Data" :on-click 'on-image-to-data) (create-gui-menu-item tools :content "Image to Data" :on-click 'on-image-to-data)
(create-gui-menu-item tools :content "Launch DB Admin" :on-click
(lambda (obj)
(declare (ignore obj))
(open-window (window body) "/dbadmin")))
(create-gui-menu-item win :content "Maximize All" :on-click #'maximize-all-windows) (create-gui-menu-item win :content "Maximize All" :on-click #'maximize-all-windows)
(create-gui-menu-item win :content "Normalize All" :on-click #'normalize-all-windows) (create-gui-menu-item win :content "Normalize All" :on-click #'normalize-all-windows)
(create-gui-menu-window-select win) (create-gui-menu-window-select win)