drag/drop support

This commit is contained in:
2026-05-04 13:43:05 +02:00
parent 41cd0021b0
commit 62093d486d
+34
View File
@@ -88,6 +88,40 @@
(define/public (attr/datetime attr) (define/public (attr/datetime attr)
(webview-attr/datetime wv element-id attr)) (webview-attr/datetime wv element-id attr))
(define/public (draggable! yes-no . on-drag)
(webview-set-attr! wv element-id "draggable" yes-no)
(if (eq? yes-no #f)
(send window unbind! element-id 'ondragstart)
(if (null? on-drag)
(error "Need an on-drag handler (λ (el) ...)")
(send window bind! element-id 'ondragstart
(λ (el evt data) ((car on-drag) el)))
)
)
)
(define/public (droppable! yes-no . on-drop)
(if (eq? yes-no #f)
(send window unbind! element-id 'ondrop)
(if (null? on-drop)
(error "Need an on-drop handler (λ (el) ...)")
(send window bind! element-id 'ondrop
(λ (el evt data) ((car on-drop) el)))
)
)
)
(define/public (dragover! yes-no . on-dragover)
(if (eq? yes-no #f)
(send window unbind! element-id 'ondragover)
(if (null? on-dragover)
(error "Need an on-dragover handler (λ (el) ...)")
(send window bind! element-id 'ondragover
(λ (el evt data) ((car on-dragover) el)))
)
)
)
(define/public (focus!) (define/public (focus!)
(let ((s (js (let* ((el (send document getElementById (eval element-id)))) (let ((s (js (let* ((el (send document getElementById (eval element-id))))
(if (=== el null) (if (=== el null)