From 62093d486dac5e6c61e00d8e69f9126a0335c733 Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Mon, 4 May 2026 13:43:05 +0200 Subject: [PATCH] drag/drop support --- wv-element.rkt | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/wv-element.rkt b/wv-element.rkt index 09685e8..44f47c8 100644 --- a/wv-element.rkt +++ b/wv-element.rkt @@ -88,6 +88,40 @@ (define/public (attr/datetime 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!) (let ((s (js (let* ((el (send document getElementById (eval element-id)))) (if (=== el null)