Jump to content

is handler removed after delete element?


IIYAMA

Recommended Posts

  • Moderators
  
local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) 
addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) 
destroyElement(confirmButton) 
  

Will the handler still be there?

Link to comment
  
local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) 
addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) 
destroyElement(confirmButton) 
  

Will the handler still be there?

  
local confirmButton = guiCreateButton(5, 5, 90, 70, "SPAWN!", false, spawnConfirmWindow) 
addEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) 
  
  
--- if you need destroy 
removeEventHandler("onClientGUIClick", confirmButton, spawnClientPlayer) -- to remove this event 
destroyElement(confirmButton) -- then destroy element 
  
  

Link to comment
  • Moderators

Now I get again two differed answers from two experienced posters...........

(not me "Experienced"...)

If I delete the element that is handled and after that I handle again, there won't be any errors.

Is the handler gone from the previous element?

grrrr I hate it when I can't see what happens..... :|

Link to comment
Now I get again two differed answers from two experienced posters...........

(not me "Experienced"...)

If I delete the element that is handled and after that I handle again, there won't be any errors.

Is the handler gone from the previous element?

grrrr I hate it when I can't see what happens..... :|

Is the handler gone from the previous element?

yes you should remove this handler then destroy element to prevent any errors

Link to comment

ok, either way the event handler would be destroyed, because for one, the element wouldn't exist anymore thus the event handler would be no use and wouldn't be triggered, and even if you remove the event handler, I think it would save some ram, but either way the event handler would be destroyed.

Link to comment
ok, either way the event handler would be destroyed, because for one, the element wouldn't exist anymore thus the event handler would be no use and wouldn't be triggered, and even if you remove the event handler, I think it would save some ram, but either way the event handler would be destroyed.

Great answer :arrowup:

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...