From 81db1f62e3ae84fad2b934c41c6c1656f8a93943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antti=20Korpim=C3=A4ki?= Date: Mon, 4 Mar 2024 19:45:49 +0100 Subject: [PATCH] Allow setClickableAreas to take weird objects That is, objects that are not proper objects as WebKit's JSCValue can understand them. --- example/page.html | 6 +----- main.c | 3 +++ 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/example/page.html b/example/page.html index 3cc3f84..9a9302e 100644 --- a/example/page.html +++ b/example/page.html @@ -65,11 +65,7 @@

Welcome to the future!

;(async () => { // Make the magic square clickable. let square = document.getElementById('magic-square') - let squareBounds = square.getBoundingClientRect() - await Hudkit.setClickableAreas([ - {x: squareBounds.x, y: squareBounds.y, width: - squareBounds.width, height: squareBounds.height} - ]) + await Hudkit.setClickableAreas([ square.getBoundingClientRect() ]) // Clicks flip its text between uppercase and lowercase. let state = true diff --git a/main.c b/main.c index c328c75..29bf9d6 100644 --- a/main.c +++ b/main.c @@ -844,6 +844,9 @@ int main(int argc, char **argv) { "\n return new Promise((resolve, reject) => {" "\n const id = nextCallbackId++" "\n window.Hudkit._pendingCallbacks[id] = { resolve, reject }" +"\n rectangles = rectangles.map(r => {" +"\n return { x: r.x, y: r.y, width: r.width, height: r.height }" +"\n })" "\n window.webkit.messageHandlers.setClickableAreas.postMessage({id, rectangles})" "\n })" "\n },"