Hello All,
I've run into a possible bug with Edit Boxes, while working on my Pixel Effects program. (Listed in the Showcase Forum)
I create a dialog box that captures the Width and Height that the user enters into the EditBoxes and then I use those values to alter the size of the Canvas.
The first time through, all is well and the new Canvas size is displayed.
On the second, and subsequent, calls to the function, the Editboxes only return Zeroes for values.
I have recreated the issue in this code:
SetWindowSize(800, 600, 0)
SetVirtualResolution(800, 600)
Again:
nsLeft = 10: nsTop = 60
nsPanel = CreateSprite(0): SetSpriteSize(nsPanel, 170, 120): SetSpritePosition(nsPanel, nsLeft, nsTop): SetSpriteColor(nsPanel, 75, 75, 75, 255)
// Setup Width Edit Box and Text
nsWidth = CreateEditBox(): SetEditBoxPosition(nsWidth, nsLeft + 90, 75): SetEditBoxSize(nsWidth, 64, 24)
SetEditBoxBackgroundColor(nsWidth, 75, 75, 75, 255): SetEditBoxTextColor(nsWidth, 200, 200, 200): SetEditBoxTextSize(nsWidth, 16)
nsWText = CreateText("Width: "): SetTextPosition(nsWText, nsLeft + 20, 75): SetTextSize(nsWText, 16)
// Setup Height Edit Box and Text
nsHeight = CreateEditBox(): SetEditBoxPosition(nsHeight, nsLeft + 90, 115): SetEditBoxSize(nsHeight, 64, 24)
SetEditBoxBackgroundColor(nsHeight, 75, 75, 75, 255): SetEditBoxTextColor(nsHeight, 200, 200, 200): SetEditBoxTextSize(nsHeight, 16)
nsHText = CreateText("Height: "): SetTextPosition(nsHText, nsLeft + 10, 115): SetTextSize(nsHText, 16)
// Setup Okay Button
nsOkay = CreateSprite(0): SetSpriteSize(nsOkay, 70, 24): SetSpritePosition(nsOkay, nsLeft + 10, 150): SetSpriteColor(nsOkay, 100, 100, 100, 255)
nsOText = CreateText("Okay"): SetTextSize(nsOText, 16): SetTextPosition(nsOText, nsLeft + 24, 154): SetTextColor(nsOText, 200, 200, 200, 255)
// Setup Cancel Button
nsCancel = CreateSprite(0): SetSpriteSize(nsCancel, 70, 24): SetSpritePosition(nsCancel, nsLeft + 90, 150): SetSpriteColor(nsCancel, 100, 100, 100, 255)
nsCText = CreateText("Cancel"): SetTextSize(nsCText, 16): SetTextPosition(nsCText, nsLeft + 96, 154): SetTextColor(nsCText, 200, 200, 200, 255)
disp1 = CreateText(""): SetTextSize(disp1, 16): SetTextPosition(disp1, 0, 0)
disp2 = CreateText(""): SetTextSize(disp2, 16): SetTextPosition(disp2, 0, 20)
SetEditBoxActive(nsWidth, 1)
SetEditBoxActive(nsHeight, 1)
do
// Okay Pressed
if GetPointerPressed() = 1 and GetSpriteHit(GetPointerX(), GetPointerY()) = nsOkay
SetTextString(disp1, str(val(GetEditBoxText(nsWText))))
SetTextString(disp2, str(val(GetEditBoxText(nsHText))))
endif
// Cancel Pressed
if GetPointerPressed() = 1 and GetSpriteHit(GetPointerX(), GetPointerY()) = nsCancel
exit
endif
sync()
loop
DeleteSprite(nsPanel): DeleteSprite(nsOkay): DeleteSprite(nsCancel)
DeleteEditBox(nsWidth): DeleteEditBox(nsHeight)
DeleteText(nsWText): DeleteText(nsHText): DeleteText(nsOText): DeleteText(nsCText): DeleteText(disp1): DeleteText(disp2)
Goto Again
Clicking the OKAY button displays the values from the EditBoxes. Clicking CANCEL deletes all assets and then calls the routine again to re-create the assets. Now the values show up as Zeroes, instead of what is entered into the EditBoxes.
I think the problem has something to do with the fact that I am DELETING all of the dialog box assets and re-creating them when the function is called again.
I suppose I could just hide them and reposition them when the function is called again, but if this is a bug, I wanted to expose it, so it could be looked into.
Thank you!
JHA
Also: For whatever reason, the text in the EditBoxes is not visible, in my Pixel Effects program, although it seems to be fine in the code above.
Using AGK2 - Tier 1 - Version 2.0.12
Proverbs Challenge: http://pc.potentialsunleashed.com/
Using AppGameKit V2 Tier 1 - FPSC Reloaded / Game Guru