Skip to content

Commit

Permalink
canvas wrap hiddeninput by form
Browse files Browse the repository at this point in the history
  • Loading branch information
lee committed Oct 4, 2024
1 parent 6792a17 commit 56a8861
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
10 changes: 6 additions & 4 deletions extern/util/CanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
},
true
); // create the hidden input element
self._hiddenForm = document.createElement('form');

self._hiddenInput = document.createElement('input');
self._hiddenInput.className = 'entryCanvasHiddenInput';
self._hiddenInput.type = 'text';
Expand All @@ -156,8 +156,8 @@
if (self._maxlength) {
self._hiddenInput.maxLength = self._maxlength;
}
self._hiddenForm.appendChild(self._hiddenInput);
document.body.appendChild(self._hiddenForm);

document.body.appendChild(self._hiddenInput);
self._hiddenInput.value = self._value; // setup the keydown listener

self._hiddenInput.addEventListener('keydown', function(e) {
Expand Down Expand Up @@ -761,7 +761,9 @@
);
input.style.width = self._width;
input.style.height = 0;
document.body.appendChild(input);
const form = document.createElement('form');
form.appendChild(input);
document.body.appendChild(form);
input.focus();
input.addEventListener(
'blur',
Expand Down
8 changes: 4 additions & 4 deletions src/class/pixi/etc/PIXICanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,6 @@ import * as PIXI from 'pixi.js';
);

// create the hidden input element
self._hiddenForm = document.createElement('form');
self._hiddenInput = document.createElement('input');
self._hiddenInput.className = 'entryCanvasHiddenInput';
self._hiddenInput.type = 'text';
Expand All @@ -158,8 +157,7 @@ import * as PIXI from 'pixi.js';
if (self._maxlength) {
self._hiddenInput.maxLength = self._maxlength;
}
self._hiddenForm.appendChild(self._hiddenInput);
document.body.appendChild(self._hiddenForm);
document.body.appendChild(self._hiddenInput);
self._hiddenInput.value = self._value;

// setup the keydown listener
Expand Down Expand Up @@ -792,7 +790,9 @@ import * as PIXI from 'pixi.js';
(self._canvas ? self._canvas.offsetTop : 0)}px`;
input.style.width = self._width;
input.style.height = 0;
document.body.appendChild(input);
const form = document.createElement('form');
form.appendChild(input);
document.body.appendChild(form);
input.focus();
input.addEventListener(
'blur',
Expand Down

0 comments on commit 56a8861

Please sign in to comment.