Skip to content

Commit

Permalink
Allow setClickableAreas to take weird objects
Browse files Browse the repository at this point in the history
That is, objects that are not proper objects as WebKit's JSCValue can
understand them.
  • Loading branch information
anko committed Mar 4, 2024
1 parent 108c2ac commit 81db1f6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 1 addition & 5 deletions example/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ <h1>Welcome to the future!</h1>
;(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
Expand Down
3 changes: 3 additions & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },"
Expand Down

0 comments on commit 81db1f6

Please sign in to comment.