Skip to content

Commit

Permalink
#8743
Browse files Browse the repository at this point in the history
모바일 keydown이벤트 동작하지 않는 문제 수정.
  • Loading branch information
lee committed Oct 4, 2024
1 parent 2fa2a9e commit 6a341a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
27 changes: 14 additions & 13 deletions extern/util/CanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
self._selection = [0, 0];
self._wasOver = false;
self._topPosition = o.topPosition; // parse box shadow

self._hasHiddenFocus = false;
self.boxShadow(self._boxShadow, true); // calculate the full width and height with padding, borders and shadows

self._calcWH(); // setup the off-DOM canvas
Expand Down Expand Up @@ -142,14 +142,6 @@
true
); // create the hidden input element

window.addEventListener('keydown', (e) => {
if (self._hasFocus) {
var keyCode = e.keyCode || e.which;
console.log('window keydown', keyCode);
// self.keydown(e, self);
}
}, true);

self._hiddenInput = document.createElement('input');
self._hiddenInput.className = 'entryCanvasHiddenInput';
self._hiddenInput.type = 'text';
Expand Down Expand Up @@ -189,6 +181,13 @@
}
}); // add this to the buffer

self._hiddenInput.addEventListener('focus', function(e) {
self._hasHiddenFocus = true;
});
self._hiddenInput.addEventListener('blur', function(e) {
self._hasHiddenFocus = false;
});

inputs.push(self);
self._inputsIndex = inputs.length - 1; // draw the text box

Expand Down Expand Up @@ -775,7 +774,9 @@
input.addEventListener(
'blur',
function() {
self.blur(self);
if (!self._hasHiddenFocus) {
self.blur(self);
}
},
false
);
Expand All @@ -784,7 +785,7 @@
} // move the real focus to the hidden input

var hasSelection = self._selection[0] > 0 || self._selection[1] > 0;

self._hasHiddenFocus = true;
self._hiddenInput.focus();

self._hiddenInput.selectionStart = hasSelection ? self._selection[0] : self._cursorPos;
Expand Down Expand Up @@ -830,12 +831,12 @@
* @return {CanvasInput}
*/
keydown: function keydown(e, self) {
var keyCode = e.keyCode || e.which;
var keyCode = e.which;
var isShift = e.shiftKey;
var key = null;
var startText;
var endText; // make sure the correct text field is being updated
console.log('keydown', keyCode);

if (!self._hasFocus) {
return;
} // fire custom user event
Expand Down
13 changes: 12 additions & 1 deletion src/class/pixi/etc/PIXICanvasInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import * as PIXI from 'pixi.js';
self._selection = [0, 0];
self._wasOver = false;
self._topPosition = o.topPosition;
self._hasHiddenFocus = false;

// parse box shadow
self.boxShadow(self._boxShadow, true);
Expand Down Expand Up @@ -183,6 +184,13 @@ import * as PIXI from 'pixi.js';
}
});

self._hiddenInput.addEventListener('focus', function(e) {
self._hasHiddenFocus = true;
});
self._hiddenInput.addEventListener('blur', function(e) {
self._hasHiddenFocus = false;
});

// add this to the buffer
inputs.push(self);
self._inputsIndex = inputs.length - 1;
Expand Down Expand Up @@ -794,7 +802,9 @@ import * as PIXI from 'pixi.js';
input.addEventListener(
'blur',
() => {
self.blur(self);
if (!self._hasHiddenFocus) {
self.blur(self);
}
},
false
);
Expand All @@ -804,6 +814,7 @@ import * as PIXI from 'pixi.js';

// move the real focus to the hidden input
const hasSelection = self._selection[0] > 0 || self._selection[1] > 0;
self._hasHiddenFocus = true;
self._hiddenInput.focus();
self._hiddenInput.selectionStart = hasSelection ? self._selection[0] : self._cursorPos;
self._hiddenInput.selectionEnd = hasSelection ? self._selection[1] : self._cursorPos;
Expand Down

0 comments on commit 6a341a6

Please sign in to comment.