diff --git a/source/clog-base.lisp b/source/clog-base.lisp index b5f466d..2390c33 100644 --- a/source/clog-base.lisp +++ b/source/clog-base.lisp @@ -614,6 +614,17 @@ is nil unbind the event.")) (defmethod set-on-change ((obj clog-obj) 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 ;; ;;;;;;;;;;;;;;;;;;;;;;; diff --git a/source/clog.lisp b/source/clog.lisp index 7fbd0e5..3aebaf1 100644 --- a/source/clog.lisp +++ b/source/clog.lisp @@ -137,6 +137,7 @@ embedded in a native template application.)" (set-on-focus generic-function) (set-on-blur generic-function) (set-on-change generic-function) + (set-on-input generic-function) (set-on-drag-start generic-function) (set-on-drag generic-function) (set-on-drag-end generic-function) diff --git a/templates/projects/clog-plugin/tmpl-tools.lisp.lt b/templates/projects/clog-plugin/tmpl-tools.lisp.lt index f42467d..61a1313 100644 --- a/templates/projects/clog-plugin/tmpl-tools.lisp.lt +++ b/templates/projects/clog-plugin/tmpl-tools.lisp.lt @@ -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")) diff --git a/templates/projects/clog-plugin/tmpl.lisp.lt b/templates/projects/clog-plugin/tmpl.lisp.lt index 60a69de..5034035 100644 --- a/templates/projects/clog-plugin/tmpl.lisp.lt +++ b/templates/projects/clog-plugin/tmpl.lisp.lt @@ -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)) - diff --git a/tools/clog-builder-settings.lisp b/tools/clog-builder-settings.lisp index ff475c8..dd21a77 100644 --- a/tools/clog-builder-settings.lisp +++ b/tools/clog-builder-settings.lisp @@ -741,6 +741,8 @@ :parameters "target") (:name "on-change" :parameters "target") + (:name "on-input" + :parameters "target") (:name "on-focus-in" :parameters "target") (:name "on-focus-out" diff --git a/tools/clog-builder.lisp b/tools/clog-builder.lisp index 0b082ef..31b61c4 100644 --- a/tools/clog-builder.lisp +++ b/tools/clog-builder.lisp @@ -651,7 +651,7 @@ not a temporary attached one when using select-control." (package (attribute content "data-in-package")) (slots (attribute content "data-custom-slots")) (cname (attribute content "data-clog-name")) - cmembers vars events) + cmembers vars creates events) (unless (or (equal slots "") (equal slots "undefined")) (push slots cmembers)) @@ -720,7 +720,7 @@ not a temporary attached one when using select-control." ~A\)~%" vname handler) - events))))) + creates))))) (add-siblings (first-child control))) (setf control (next-sibling control)))))) (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\)\) \(let \(\(panel \(change-class \(clog:create-div clog-obj :content \"~A\" :hidden hidden :class class :html-id html-id :auto-place auto-place\) \'~A\)\)\) -~{~A~}~{~A~} panel\)\)~%" +~{~A~}~{~A~}~{~A~} panel\)\)~%" (string-upcase package) cname ;;defclass cmembers @@ -751,7 +751,8 @@ not a temporary attached one when using select-control." "\\\"") cname 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) (declare (ignore html-id)) (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 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 "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 "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 "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 "Normalize All" :on-click #'normalize-all-windows) (create-gui-menu-window-select win)