Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Feature request (https://forums.graalonline.com/forums/forumdisplay.php?f=194)
-   -   findgui() function (https://forums.graalonline.com/forums/showthread.php?t=76334)

Relinquish 08-17-2007 10:47 PM

findgui() function
 
Any chance of getting a findgui() function? It returns a reference to the GUI control with the name given.

I'd like to have a class that draws on whichever DrawingPanel control I pass it, but as far as I can tell, there's no way to pass a reference to it or get it from the name. Unless I'm doing something wrong.

I've tried
PHP Code:

with (@guinamedrawstuff();
(@
guiname).drawstuff();
guiname.drawstuff(); 

Am I missing anything?

Chompy 08-17-2007 11:00 PM

GuiControls are objects, so yes

GuiName.drawStuff();
Should work, unless you're doing something wrong in the script itself..

Post some part of your script?

DustyPorViva 08-17-2007 11:15 PM

with ("guiname") {
blah...
}
or, the same thing Chompy said.
The quotations aren't necessary, but needed if you have spaces in the gui name(which you shouldn't), and the gui name is case sensitive, so make sure you do the name exactly as the gui name is when created.

Relinquish 08-17-2007 11:30 PM

Echoes nothing (guiref is treated as a string)
PHP Code:

DrawText(("TextTip"));

function 
DrawText(guiref) {
  echo(
guiref.position);


Echoes nothing (guiref is treated as a string)
PHP Code:

DrawText("TextTip");

function 
DrawText(guiref) {
  echo((@
guiref).position);


Echoes nothing (I'm not sure what it's getting, I'm assuming nothing)
PHP Code:

DrawText("TextTip");

function 
DrawText(guiref) {
  
with (guiref) echo(this.position);


TextTip is the name of a GuiDrawingPanel.

DustyPorViva 08-17-2007 11:40 PM

echo(TextTip.position);

Relinquish 08-17-2007 11:41 PM

You don't understand the original problem.

I want to be able to pass the function which GUI control I want it to draw on; it's dynamic, not static.

Skyld 08-17-2007 11:46 PM

I am not entirely sure I understand what you are trying to do, but in order to pass a GUI object to a function:
PHP Code:

//#CLIENTSIDE

function moveMyControl(temp.obj)
{
  
// Check if temp.obj is an object
  // This will usually be your GuiControl object reference

  
if (temp.obj.type() != 2)
  {
    return 
false;
  }

  
// Check if it has a child this.drawingpanel

  
if (temp.obj.drawingpanel == NULL)
  {
    return 
false;
  }

  
// Perform your action in the scope of the control

  
with (temp.obj)
  {
    
this.position = {2020};
  }

  return 
true;
}

function 
onCreated()
{
  new 
GuiWindowCtrl(TestControl)
  {
    
position = {4040};
    
extent = {100100};

    
text "My Window";
  }

  
// Provide a direct object reference

  
this.moveMyControl(TestControl);

  
// Alternatively use the (@ "") syntax to pass an object reference from a string name

  
this.moveMyControl((@ "TestControl"));


Now let's say each control has a child object, you can probably do something like this:
PHP Code:

//#CLIENTSIDE

function drawAction(temp.obj)
{
  
// Check if temp.obj is an object
  // This will usually be your GuiControl object reference

  
if (temp.obj.type() != 2)
  {
    return 
false;
  }

  
// Perform your action in the scope of the control

  
with (temp.obj.drawingpanel)
  {
    
this.drawimagerectangle(...);
  }

  return 
true;
}

function 
onCreated()
{
  new 
GuiWindowCtrl(TestControl)
  {
    
position = {4040};
    
extent = {100100};

    
text "My Window";

    
this.drawingpanel = new GuiDrawingPanel();
  }

  
// Provide a direct object reference

  
this.drawAction(TestControl);



Relinquish 08-18-2007 12:05 AM

Very messy/inconvenient, but it works, thanks.

Admins 08-28-2007 11:05 AM

(@guiname).drawstuff() is the prefered method, but guiname must be correctly written

zokemon 08-28-2007 05:02 PM

I'm not sure if there is anything that holds priority with variable names over GUIs but if there is (for example say that you had a NPC named ChatBar that held priority over the GUI), such a function might be useful.


All times are GMT +2. The time now is 10:39 AM.

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