Shift drag to make control child to drop target

This commit is contained in:
David Botton 2022-01-16 12:02:40 -05:00
parent 0aafec2da8
commit c993bb70de
2 changed files with 13 additions and 3 deletions

View file

@ -308,6 +308,7 @@ result or if time out DEFAULT-ANSWER (Private)"))
(defparameter drop-event-script
"+ (e.clientX - e.currentTarget.getBoundingClientRect().left + e.currentTarget.scrollLeft) + ':' +
(e.clientY - e.currentTarget.getBoundingClientRect().top + e.currentTarget.scrollTop) + ':' +
e.which + ':' + e.altKey + ':' + e.ctrlKey + ':' + e.shiftKey + ':' + e.metaKey + ':' +
encodeURIComponent(e.originalEvent.dataTransfer.getData('~A'))"
"JavaScript to collect drop event data from browser.")
@ -317,7 +318,12 @@ result or if time out DEFAULT-ANSWER (Private)"))
:event-type :drop
:x (parse-integer (nth 0 f) :junk-allowed t)
:y (parse-integer (nth 1 f) :junk-allowed t)
:drag-data (quri:url-decode (or (nth 2 f) "")))))
:which-button (parse-integer (nth 2 f) :junk-allowed t)
:alt-key (js-true-p (nth 3 f))
:ctrl-key (js-true-p (nth 4 f))
:shift-key (js-true-p (nth 5 f))
:meta-key (js-true-p (nth 6 f))
:drag-data (quri:url-decode (or (nth 7 f) "")))))
;;;;;;;;;;;;;;;
;; set-event ;;

View file

@ -59,7 +59,9 @@
:create clog:create-div
:create-type :element
:create-content ""
:properties ((:name "positioning"
:properties ((:name "text"
:prop clog:text)
(:name "positioning"
:prop clog:positioning)
(:name "color"
:prop clog:color)
@ -396,7 +398,9 @@ of controls and double click to select control."
(control2 (attach-as-child obj (getf data :drag-data)))
(placer1 (get-placer control1))
(placer2 (get-placer control2)))
(place-before control1 control2)
(if (getf data :shift-key)
(place-inside-bottom-of control1 control2)
(place-before control1 control2))
(place-after control2 placer2)
(set-geometry placer1 :top (position-top control1)
:left (position-left control1)