GUI Editbox error

Started by Zone_Killer, Dec 09, 2017, 02:38 PM

Previous topic - Next topic

Zone_Killer

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+".");
}

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

Try this:

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+".");
}
if( !sucess ) tryAgain();
Thanks to the VCMP community. It was the happiest period of my life.

Zone_Killer

Bohemia Is God Of Punjabi Rap
Yo Yo Honey Singh tou chutiya hai