Here is my class & it's constructors for some textboxes:
class textbox {
char curtxt[255];
int XPos;
int YPos;
int Sprite;
int SpriteX;
int SpriteY;
bool selected;
public:
void Make ( int x, int y, int sprite, int spritex, int spritey );
void Do ( );
};
void textbox::Make( int x, int y, int sprite, int spritex, int spritey )
{
selected = false;
XPos = x;
YPos = y;
Sprite = sprite;
SpriteX = spritex;
SpriteY = spritey;
}
void textbox::Do()
{
int mc = dbMouseClick();
int mx = dbMouseX();
int my = dbMouseY();
if (mc == 1)
{
if (mx > XPos+5 && mx < XPos+SpriteX-5 && my > YPos+6 && my < YPos+SpriteY-6)
{
selected = true;
} else {
selected = false;
}
}
if (selected == true)
{
if (dbReturnKey() == 1)
{
//delete curtxt[255];
char curtext[255];
}
if (dbGetEntry ( ) > 0)
{
strcat ( curtxt, dbGetEntry ( ) );
}
}
dbPasteSprite ( Sprite, XPos, YPos );
dbText ( XPos+10, YPos+12, curtxt );
dbClearEntryBuffer ( );
}
textbox input[10];
I'm posting it because, well, it won't work properly.
All you have to do to use it is, call the Make constructor once & the Do constructor every frame.
What Works:
Yes you can create 1 textbox,
If you click in it and type text appears,
If you click out of it and type no text appears,
If you click out of it then click back in it you continue typing where you left off,
Issues:
Try and make more than 1 all but the first have problems
(thats the only problem)
Whats going on here? It shouldnt be doing this bad error poo poo stuff >.<