Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / [Bug] GetPointerX() and GetPointerY() not registering when EditBox has focus

Author
Message
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 15th Feb 2019 21:50
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.



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
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Feb 2019 22:06
Have you tried the GetRaw functions like GetRawTouchCurrentX()?
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 15th Feb 2019 22:40 Edited at: 15th Feb 2019 22:42
I haven't actually used the GetRawTouch functions before. But trying it with one of the help example scripts (a zoom screen example) it doesn't work if the editbox is selected first.

Here's the code I found: https://www.appgamekit.com/documentation/Reference/Input-Raw/GetRawFirstTouchEvent.htm

And here's that code with an edit box added and two print lines.

OryUI - A WIP AGK2 UI Framework
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 15th Feb 2019 22:55 Edited at: 15th Feb 2019 22:57
I think I'm going to have to hide all of the textboxes off screen show sprites and text that looks like an editbox with a pencil icon next to them that when pressed will replace the label with the edit box. They still won't be able to scroll when editing the text in the editbox, but they've specifically chosen to edit the editbox so not as bad. With all of the textboxes hidden off screen they will be able to scroll without triggering any edit box focusing.
OryUI - A WIP AGK2 UI Framework
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Feb 2019 22:57 Edited at: 15th Feb 2019 22:57
That sounds like a good idea. Could you manage activating the textbox so that when they tap on the text it activates the box but not when they swipe?
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 15th Feb 2019 23:21
I'll have a go, although I've just seen that a simpler approach with the pencil idea is to just set the edit boxes as active = 0. Setting them as active = 0 in my first post and it scrolls fine. I could have a pencil that sets them as active = 1, or maybe an invisible sprite over the top that when pressed it sets them as active as long as the screen isn't being dragged. I'll see what works best.
OryUI - A WIP AGK2 UI Framework
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Feb 2019 23:29 Edited at: 15th Feb 2019 23:30
You can use SetEditboxActive() to disable the edit box until you get the appropriate touch event. Then you can activate it and use seteditboxfocus() to give it focus.
Didn't test that second bit out but i works in my head

Sorry. Didn't see your post
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 15th Feb 2019 23:35 Edited at: 15th Feb 2019 23:38
Sorted I went with an invisible sprite above the editbox and editboxes set as active = 0 by default. press the invisible sprite and the editbox becomes active and gets focus.

This works fine on mobile and desktop.

OryUI - A WIP AGK2 UI Framework
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 15th Feb 2019 23:46
Nice. It really works well

Login to post a reply

Server time is: 2024-11-05 23:04:02
Your offset time is: 2024-11-05 23:04:02