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 Studio Chat / Edit Box Text Alignment

Author
Message
jd_zoo
5
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 18th Aug 2020 01:07
Is there a technique for this or is it a feature that has already been requested?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 18th Aug 2020 02:06 Edited at: 18th Aug 2020 02:22
SetTextAlignment()
Sorry, you said edit box. I don't think that's an option right now

I remember that someone had rolled their own text input (for mobile). Somewhere on the boards but i can't seem to find it right now. If your looking to customize that might be an option.
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 18th Aug 2020 19:23 Edited at: 18th Aug 2020 19:25
I have done this, but don't have any code that's easy to get to. It would be in an old version of my app that's archived.

Here's the general idea:

* You have an edit box that's off screen.
* You create what looks like an edit box with sprites and text i.e. a white sprite for the background, and text that sits on top and is centred.
* When you tap on the fake edit box you set focus of the real edit box and when you type in the hidden edit box you update the text that's displayed in the fake edit box which is centred.

This loses some functionality but the edit boxes have very little functionality anyway. For example you lose a blinking cursor line and you can't move the blinking cursor but that's probably it.

What I did was clear the text from the real edit box which cleared the fake one whenever the user tapped on the fake edit box. If you don't want to clear it every time it's tapped then add a small button to the right and inside of the fake edit box that when pressed will clear the text.

OryUI has fancier looking textfields but it doesn't let you centre the text
OryUI - A WIP AGK2 UI Framework
jd_zoo
5
Years of Service
User Offline
Joined: 12th May 2018
Location: Nova Scotia
Posted: 18th Aug 2020 20:34
Thanks Kevin, the off screen idea is quite elegant actually - potential to have it hidden or underneath the fake box and incorporated as one custom object. Actually now thinking about it I could make the edit box text the same colour as the edit box background and use a separate text object on top of it all, I may end up exploring this. Bonus functionality of being able to clear the text automatically I can see opportunities for that as well. Would also be nice to have an option to have all the text highlighted when an edit box becomes active so just start typing to clear it.

Would be good to see this stuff as core AppGameKit functionality. I also need to keep track of them all as there is no DeleteAllEditBoxes() that I have found...

Login to post a reply

Server time is: 2024-04-25 16:41:55
Your offset time is: 2024-04-25 16:41:55