Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   parent delay? (https://forums.graalonline.com/forums/showthread.php?t=71839)

xXziroXx 01-31-2007 11:43 AM

parent delay?
 
Ive noticed a "delay" of some sort when parent.mod is being called upon "onCreated".

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiWindowCtrl("ChatWindow_Main") {
    
width 200height 400;
    
screenwidth/width/2screenheight/height/2;
    
    
//visible = false;
    
    
new GuiMLTextCtrl("ChatWindow_Text") {
      
width parent.width 14height parent.height 30;
      
825;

      
setText("This is my text!");
    }
  }


When I do that, the width and height of ChatWindow_Text is at default value. However, it works if I do this:

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiWindowCtrl("ChatWindow_Main") {
    
width 200height 400;
    
screenwidth/width/2screenheight/height/2;
    
    
//visible = false;
    
    
new GuiMLTextCtrl("ChatWindow_Text") {
      
width ChatWindow_Main.width 14height ChatWindow_Main.height 30;
      
825;


      
setText("This is my text!");
    }
  }



If I created the GUI first, and then try reading the parent values, they all match up to the proper value.

Inverness 01-31-2007 12:30 PM

Oh yea, I had this exactly same problem and it gave me such a headache >_>. Until I figured out that parent was set after the thing finished.
I suppose you could create all the GUI Controls first then edit them using with (ControlName) {}

Admins 01-31-2007 12:55 PM

The new GuiControl() {} thing is a combination of new, with (control) { } and addcontrol(control), so the parent is not set before it is actually added at the end of the command.

zokemon 01-31-2007 09:26 PM

I was going to say that...

Using new does not define the parent until after the new is finished. It is better to do the addcontrol() inside the new before you call the parent or to just use onResize() functions for defining child positions (You could make a chain reaction from the GUIControl all the way down to the position of a radio button or something and then call the function at the end of your GUI Creation script so everything get positioned)

xXziroXx 02-01-2007 06:37 AM

Quote:

Originally Posted by zokemon (Post 1271751)
I was going to say that...

Using new does not define the parent until after the new is finished. It is better to do the addcontrol() inside the new before you call the parent or to just use onResize() functions for defining child positions (You could make a chain reaction from the GUIControl all the way down to the position of a radio button or something and then call the function at the end of your GUI Creation script so everything get positioned)

Seeing as though Ive never done that, care to give an example?


All times are GMT +2. The time now is 12:07 AM.

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