Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Close GUI on button click? (https://forums.graalonline.com/forums/showthread.php?t=134257982)

Jimbo33 02-12-2010 12:41 AM

Close GUI on button click?
 
Hi,
I want my GUI to close when the player presses a button...
Here are the two parts of my GUI Script about the button I want
to close the whole GUI:

HTML Code:

    new GuiButtonCtrl("ClassSelect_Button3") {
      profile = GuiBlueButtonProfile;
      text = "Swordsman";
      width = 80;
      x = 10;
      y = 200;
    }

...

HTML Code:

function ClassSelect_Button3.onAction() {
//Stuff
}


Please help, all I need is the command to close everything and where to put it, thanks :)

Engine 02-12-2010 01:10 AM

i'm fairly sure it's
PHP Code:

new GuiButtonCtrl("ClassSelect_main"){
//blahblah
    
new GuiButtonCtrl("ClassSelect_Button3") {
      
profile GuiBlueButtonProfile;
      
text "Swordsman";
      
width 80;
      
10;
      
200;
    }
}
function 
ClassSelect_Button3.onAction() {
ClassSelect_main.destroy();



Jimbo33 02-12-2010 01:18 AM

Oh yeah it worked!

I was doing

ClassSelect.destroy();

but it was actually
ClassSelect_Main.destroy();
like you said

Thanks :)

DustyPorViva 02-12-2010 01:39 AM

If it's a GUI that will be used fairly often, or even not that often, it's better to just .hide() it rather than constantly recreating it every time it's needed. I've asked about this and Stefan has confirmed that create/destroy should only be reserved for single-use GUI's.


All times are GMT +2. The time now is 09:27 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.