Zone_Killer

  • Jr. Member
  • K.D.M No.1
  • Posts: 99
GUI Editbox error
«  »
Code: [Select]
function GUI::ElementRelease(element, mouseX, mouseY)
{
try{
if(element == Button)
{
local Data = Stream();
Data.WriteString(Editbox.Text);
Data.WriteInt(3);
Server.SendData(Data);
}
}
catch(e) Console.Print("Error "+e+".");
}

Code: [Select]
Editbox <- GUIEditbox(VectorScreen( 50, 50), VectorScreen(100, 50 ), Colour(255,255,255,190))
 Button <- GUIButton( VectorScreen( 50, 50), VectorScreen(20,10 ), Colour(0,255,255,190), "button");

but when i click on 'Button' So it comes "Index 'Editbox' does not exists.
please help me.
Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai

MatheuS

  • Wiki Contributor
  • LBR | Co-Leader & Brasil Real RPG | Developer
  • Posts: 449
Re: GUI Editbox error
« Reply #1,  »
Try this:

Code: [Select]
MyFirstMenu <-
{
     Editbox = null;
     Button = null;
}

MyFirstMenu.Editbox = GUIEditbox(VectorScreen( 50, 50), VectorScreen(100, 50 ), Colour(255,255,255,190))
MyFirstMenu.Button = GUIButton( VectorScreen( 50, 50), VectorScreen(20,10 ), Colour(0,255,255,190), "button");

function GUI::ElementRelease(element, mouseX, mouseY)
{
 try{
if(element == ::MyFirstMenu.Button) // if not works you can remove ::
{
local Data = Stream();
Data.WriteString(::MyFirstMenu.Editbox.Text);
Data.WriteInt(3);
Server.SendData(Data);
}
}
catch(e) Console.Print("Error "+e+".");
}
Code: [Select]
if( !sucess ) tryAgain();

Zone_Killer

  • Jr. Member
  • K.D.M No.1
  • Posts: 99
Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai