View Single Post
  #5  
Old 01-21-2010, 06:10 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Grey View Post
I think running through all of the controls is the only way given what I'm doing. New Gui Controls are generated for each item in a list, and when a new list is referenced the old Controls are being removed from the GUI.

Though I'm also thinking now it'd be faster / better to just replace Controls where applicable rather than destroying / recreating.
This is exactly what catchevent is for. Just place the catchevent in the dynamic GUI controls and it will call the function for all of them, and thus you can control them with one single function.

For example:
PHP Code:
function onCreated() {
  for (
temp.i=0;i<10;i++) {
    new 
GuiControl("Name" i) {
      
catchevent(this.name,"onMousedown","onGUIclicked");
    }
  }
}

function 
onGUIclicked(obj,keymod,mx,my,clicks) {
  
player.chat obj.name " was clicked at " mx SPC my  ", " clicks " times!";

Will set the player's chat to 'Name0', 'Name1' and so on and so forth, for each dynamic GUI you click on. You don't have to worry about handling all the variables and such. You just have one function for it all. In fact, the name of the GUI becomes irrelevant at this point.
Reply With Quote