implement wait-for-element (to be accessable in DOM)

This commit is contained in:
2026-04-15 23:32:13 +02:00
parent cd12da48c1
commit dfe112dd51

View File

@@ -132,11 +132,23 @@
(set! elem (new cl [window this] [element-id id]))
(hash-set! element-hash id elem))
)
(displayln (format "element ~a: ~a" id elem))
;(displayln (format "element ~a: ~a" id elem))
elem
)
)
(define (wait-for-element id)
(webview-call-js wv (string-append
(format "{ let el = document.getElementById('~a');" id)
" while (el === null) { "
" window.setTimeout(function (){ }, 0);"
(format " el = document.getElementById('~a');" id)
" }"
" return true;"
"}")
)
)
(define (connect! id type event callback)
(let ((elem (element id type)))
(send elem add-event-callback! event callback)