GUI Button click
Posted: Thu Sep 03, 2009 5:51 pm
Hi,
I created a login form and added login and password edit boxes.
I have a couple of issues.
1. I have to check the user name and password on the editbox when I click "LOGIN" button. I dont know how to do the event receiver.
I tried this,
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
{
IGUIButton* button = (IGUIButton*)event.GUIEvent.Caller;
if(button->getID() == 1)
buttonPressed = true;
}
......
But this doesnt work.
2. I added all the elements as a child to the loginForm.
But still If I move the dialog box the elements(editbox, button) disappears.
Below is my code, how I add the controls.
if(displayLoginForm)
{
loginForm = guienv->addWindow(core::rect<s32>(windowWidth/2, windowHeight/2, windowWidth/2 + 400, windowHeight/2 + 250), true, L"Login Form");
IGUIStaticText* text1 = guienv->addStaticText(L"Login Name :", core::rect<s32>(windowWidth/2 + 20, windowHeight/2 + 100, windowWidth/2 + 100, windowHeight/2 + 120));
IGUIStaticText* text2 = guienv->addStaticText(L"Password :", core::rect<s32>(windowWidth/2 + 20, windowHeight/2 + 150, windowWidth/2 + 100, windowHeight/2 + 170));
loginForm->addChild(text1);
loginForm->addChild(text2);
editBox = guienv->addEditBox(L"", core::rect<s32>(windowWidth/2 + 150, windowHeight/2 + 100, windowWidth/2 + 300, windowHeight/2 + 120),
true, 0, 1);
loginForm->addChild(editBox);
editBox = guienv->addEditBox(L"", core::rect<s32>(windowWidth/2 + 150, windowHeight/2 + 150, windowWidth/2 + 300, windowHeight/2 + 170),
true, 0, 2);
editBox->setPasswordBox(true);
loginForm->addChild(editBox);
IGUIButton* button1 = guienv->addButton(core::rect<s32>(windowWidth/2 + 150, windowHeight/2 + 180, windowWidth/2 + 200, windowHeight/2 + 200),
0, 1, L"LOGIN");
loginForm->addChild(button1);
displayLoginForm = !displayLoginForm;
}
I created a login form and added login and password edit boxes.
I have a couple of issues.
1. I have to check the user name and password on the editbox when I click "LOGIN" button. I dont know how to do the event receiver.
I tried this,
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
{
IGUIButton* button = (IGUIButton*)event.GUIEvent.Caller;
if(button->getID() == 1)
buttonPressed = true;
}
......
But this doesnt work.
2. I added all the elements as a child to the loginForm.
But still If I move the dialog box the elements(editbox, button) disappears.
Below is my code, how I add the controls.
if(displayLoginForm)
{
loginForm = guienv->addWindow(core::rect<s32>(windowWidth/2, windowHeight/2, windowWidth/2 + 400, windowHeight/2 + 250), true, L"Login Form");
IGUIStaticText* text1 = guienv->addStaticText(L"Login Name :", core::rect<s32>(windowWidth/2 + 20, windowHeight/2 + 100, windowWidth/2 + 100, windowHeight/2 + 120));
IGUIStaticText* text2 = guienv->addStaticText(L"Password :", core::rect<s32>(windowWidth/2 + 20, windowHeight/2 + 150, windowWidth/2 + 100, windowHeight/2 + 170));
loginForm->addChild(text1);
loginForm->addChild(text2);
editBox = guienv->addEditBox(L"", core::rect<s32>(windowWidth/2 + 150, windowHeight/2 + 100, windowWidth/2 + 300, windowHeight/2 + 120),
true, 0, 1);
loginForm->addChild(editBox);
editBox = guienv->addEditBox(L"", core::rect<s32>(windowWidth/2 + 150, windowHeight/2 + 150, windowWidth/2 + 300, windowHeight/2 + 170),
true, 0, 2);
editBox->setPasswordBox(true);
loginForm->addChild(editBox);
IGUIButton* button1 = guienv->addButton(core::rect<s32>(windowWidth/2 + 150, windowHeight/2 + 180, windowWidth/2 + 200, windowHeight/2 + 200),
0, 1, L"LOGIN");
loginForm->addChild(button1);
displayLoginForm = !displayLoginForm;
}