Hi all,
In an effort to make my program's ui as user-friendly as possible (!) I am trying to control the focus of edit boxes to prevent the user having to click/tap around too much.
Would you mind having a quick look at this code? In it, tab moves the focus between the boxes - this works. Enter focuses a box if it is empty or just contains spaces - this doesn't work.
// set window properties
SetWindowTitle( "Edit box test" )
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( 0, 0, 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
Eb1 = createeditbox()
seteditboxposition(Eb1,100,200)
seteditboxsize(Eb1,400,40)
seteditboxtextsize(Eb1,45)
seteditboxfocus(Eb1,1)
Eb2 = createeditbox()
seteditboxposition(Eb2,100,300)
seteditboxsize(Eb2,400,40)
seteditboxtextsize(Eb2,45)
do
print("Tab moves between boxes.")
print("Pressing enter with both boxes full ends the program.")
print("Pressing enter with a box empty moves the focus to that box. <- Doesn't work!")
print("All spaces are stripped from the string.")
// Handle tab key to move between editboxes
if (getrawkeypressed(9))
if (geteditboxhasfocus(Eb2))
seteditboxfocus(Eb1,1)
seteditboxfocus(Eb2,0)
else
seteditboxfocus(Eb1,0)
seteditboxfocus(Eb2,1)
endif
endif
// Handle enter key
if (getrawkeypressed(13))
if (stripstring(geteditboxtext(Eb1)," ") = "")
seteditboxfocus(Eb1,1)
seteditboxfocus(Eb2,0)
elseif (stripstring(geteditboxtext(Eb2)," ") = "")
seteditboxfocus(Eb1,0)
seteditboxfocus(Eb2,1)
else
end
endif
endif
sync()
loop
I think AppGameKit is trying to do something clever with the Enter key which is getting in my way
Thanks for any suggestions/advice.
Jambo