Does anyone have an idea for a workaround so that the screen will still scroll if an editbox accidentally gains focus?
Here's a simple script where you can show either a number of sprites or edit boxes and scroll/drag the screen.
Change showSprites to equal 1 and showEditBoxes to equal 0 and you will be able to drag the screen without any problems.
Change the values around so that showSprites is 0 and showEditBoxes is 1 and you will find as soon as you hit an edit box when dragging the drag screen won't happen. Not until you click out of the edit box. This is a problem with 1 editbox on the screen but more noticable if you've got multiple editboxes on the screen. A register account form for your game can have a few editboxes. They may not be as close as they are in this example but you only have to accidentally touch one when trying to scroll and the scroll won't happen.
// set window properties
SetWindowTitle( "" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
showSprites = 1
showEditBoxes = 0
sprites as integer[20]
editBoxes as integer[20]
if (showSprites)
for i = 0 to 20
sprites[i] = CreateSprite(0)
SetSpriteSize(sprites[i], 1000, 50)
SetSpritePosition(sprites[i], 12, 80 * i)
SetSpriteColor(sprites[i], random(0, 255), random(0, 255), random(0, 255), 255)
next
endif
if (showEditBoxes)
for i = 0 to 20
editBoxes[i] = CreateEditBox()
SetEditBoxSize(editBoxes[i], 1000, 50)
SetEditBoxPosition(editBoxes[i], 12, 80 * i)
SetEditBoxBackgroundColor(editBoxes[i], random(0, 255), random(0, 255), random(0, 255), 255)
SetEditBoxTextColor(editBoxes[i], 255, 255, 255)
SetEditBoxText(editBoxes[i], str(i))
SetEditBoxTextSize(editBoxes[i], 30)
next
endif
do
print(GetPointerY())
if (GetPointerPressed())
pressedY# = ScreenToWorldY(GetPointerY())
touchTime# = timer()
scrollStartY# = GetPointerY()
viewY# = GetViewOffsetY()
else
if (GetPointerState())
if (timer() - touchTime# > 0.1)
dY# = scrollStartY# - GetPointerY()
viewDY# = viewY# + dY#
SetViewOffset(GetViewOffsetX(), viewDY#)
if (abs(dY#) > 0.5)
draggingVertically = 1
endif
endif
endif
if (GetPointerReleased())
draggingVertically = 0
endif
endif
Sync()
loop
TGC, is this something that can be fixed so that it works like native textboxes? When I go to "My Account" page on the mobile Discord app I can click on the username textfield and scroll the screen. It doesn't stick because it has focus. Even when it has focus the screen can still be moved.
GetPointerX() and GetPointerY() don't change when an editbox has focus.
OryUI - A WIP AGK2 UI Framework