Skip to content

Commit

Permalink
add window scroll and canvas client bounding rect to hidden_input to …
Browse files Browse the repository at this point in the history
…support focusing nonfullscreen canvases
  • Loading branch information
MichaelBelousov committed Nov 27, 2024
1 parent 998bca2 commit 84e9ee8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/backends/WebBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ function dvui(canvasId, wasmFile) {
if (textInputRect.length == 0) {
gl.canvas.focus();
} else {
hidden_input.style.left = textInputRect[0] + 'px';
hidden_input.style.top = textInputRect[1] + 'px';
hidden_input.style.left = (window.scrollX + canvasElem.getBoundingClientRect().left + textInputRect[0]) + 'px';
hidden_input.style.top = (window.scrollY + canvasElem.getBoundingClientRect().top + textInputRect[1]) + 'px';
hidden_input.style.width = textInputRect[2] + 'px';
hidden_input.style.height = textInputRect[3] + 'px';
hidden_input.focus();
Expand Down Expand Up @@ -430,9 +430,9 @@ function dvui(canvasId, wasmFile) {
//div.style.height = 0;
//div.style.overflow = "hidden";
hidden_input = document.createElement("input");
hidden_input.style.position = "absolute";
hidden_input.style.left = 0;
hidden_input.style.top = 0;
hidden_input.style.position = "absolute";
hidden_input.style.left = (window.scrollX + canvas.getBoundingClientRect().left) + "px";
hidden_input.style.top = (window.scrollY + canvas.getBoundingClientRect().top) + "px";
div.appendChild(hidden_input);
document.body.prepend(div);

Expand Down

0 comments on commit 84e9ee8

Please sign in to comment.