From bd451b7f3194537a75974fea36594c6f977d66a1 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 16 Oct 2020 20:30:01 +1100 Subject: [PATCH] For text input on mobile web client, instead of trying to draw an invisible text input and only showing the in-game chat input, now draw a fully solid text input box over the top of the game Hopefully this makes chatting much less of a pain --- src/Window.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Window.c b/src/Window.c index cb33030ca..71fb54241 100644 --- a/src/Window.c +++ b/src/Window.c @@ -3511,15 +3511,18 @@ void Window_OpenKeyboard(const String* text, int type) { var elem = window.cc_inputElem; if (!elem) { elem = document.createElement('textarea'); - elem.setAttribute('style', 'position:absolute; left:0; top:0; width:100%; height:100%; opacity:0.3; resize:none; pointer-events:none;'); + elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px'); elem.value = UTF8ToString($0); - elem.addEventListener("input", + elem.addEventListener('input', function(ev) { ccall('Window_OnTextChanged', 'void', ['string'], [ev.target.value]); }, false); - window.cc_inputElem = elem; + + window.cc_divElem = document.createElement('div'); + window.cc_divElem.setAttribute('style', 'position:absolute; left:0; top:0; width:100%; height:100%; background-color: black; opacity:0.4; resize:none; pointer-events:none;'); + document.body.appendChild(window.cc_divElem); document.body.appendChild(elem); } elem.focus(); @@ -3547,7 +3550,9 @@ void Window_CloseKeyboard(void) { EM_ASM({ if (!window.cc_inputElem) return; + document.body.removeChild(window.cc_divElem); document.body.removeChild(window.cc_inputElem); + window.cc_divElem = null; window.cc_inputElem = null; }); }