From 2adced29004325c0d02ee020b8f1a61929fbac3f Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Wed, 3 Feb 2021 21:25:51 +1100 Subject: [PATCH] Webclient: Fix touching anywhere while keyboard was open causing touch mode to get turned off --- src/Window.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Window.c b/src/Window.c index 1684301ea..82e6e2a75 100644 --- a/src/Window.c +++ b/src/Window.c @@ -2943,7 +2943,7 @@ void Window_Create(int width, int height) { rect.size.height = height; winClass = Window_MakeClass(); - winHandle = objc_msgSend(winClass, sel_registerName("alloc")); + winHandle = objc_msgSend(winClass, sel_registerName("alloc")); // todo buffered mode objc_msgSend(winHandle, sel_registerName("initWithContentRect:styleMask:backing:defer:"), rect, (NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask), 0, false); Window_CommonCreate(); @@ -3317,9 +3317,7 @@ static EM_BOOL OnTouchStart(int type, const EmscriptenTouchEvent* ev, void* data RescaleXY(&x, &y); Input_AddTouch(t->identifier, x, y); } - /* Don't intercept touchstart events while keyboard is open, that way */ - /* user can still touch to move the caret position in input textbox. */ - return !keyboardOpen; + return true; } static EM_BOOL OnTouchMove(int type, const EmscriptenTouchEvent* ev, void* data) { @@ -3334,9 +3332,7 @@ static EM_BOOL OnTouchMove(int type, const EmscriptenTouchEvent* ev, void* data) RescaleXY(&x, &y); Input_UpdateTouch(t->identifier, x, y); } - /* Don't intercept touchmove events while keyboard is open, that way */ - /* user can still touch to move the caret position in input textbox. */ - return !keyboardOpen; + return true; } static EM_BOOL OnTouchEnd(int type, const EmscriptenTouchEvent* ev, void* data) { @@ -3351,9 +3347,7 @@ static EM_BOOL OnTouchEnd(int type, const EmscriptenTouchEvent* ev, void* data) RescaleXY(&x, &y); Input_RemoveTouch(t->identifier, x, y); } - /* Don't intercept touchend events while keyboard is open, that way */ - /* user can still touch to move the caret position in input textbox. */ - return !keyboardOpen; + return true; } static EM_BOOL OnFocus(int type, const EmscriptenFocusEvent* ev, void* data) { @@ -3852,6 +3846,12 @@ void Window_OpenKeyboard(const struct OpenKeyboardArgs* args) { elem.setAttribute('style', 'position:absolute; left:0; bottom:0; margin: 0px; width: 100%'); elem.setAttribute('placeholder', UTF8ToString($2)); elem.value = UTF8ToString($0); + + elem.addEventListener('touchstart', function(ev) { ev.stopPropagation(); }, false); + elem.addEventListener('touchmove', function(ev) { ev.stopPropagation(); }, false); + elem.addEventListener('touchend', function(ev) { ev.stopPropagation(); }, false); + elem.addEventListener('mousedown', function(ev) { ev.stopPropagation(); }, false); + elem.addEventListener('mousemove', function(ev) { ev.stopPropagation(); }, false); elem.addEventListener('input', function(ev) {