Passing data to local functions
No edit summary |
(Passing data to local functions) |
||
| Line 121: | Line 121: | ||
StaticPopup_Show ("EXAMPLE_CTRA_READY", CT_RA_CheckReady_Person); | StaticPopup_Show ("EXAMPLE_CTRA_READY", CT_RA_CheckReady_Person); | ||
== Passing Arguments to Local Functions == | |||
It is possible, though not immediately obvious how, to pass arbitrary user data to the local functions (e.g. OnAccept, OnCancel). | |||
Write your local function like this: | |||
OnAccept = function(argName) | |||
DoSomethingWith(argName) | |||
end | |||
And make the call like this: | |||
varName = "Some value" -- This is the data you want to use in OnAccept | |||
local dialog = StaticPopup_Show("YOUR_POPUP") -- dialog contains the frame object | |||
if(dialog) then | |||
dialog.data = varName -- set the frame's data to the value you want | |||
end | |||
If you'll notice, you are actually setting the frame's data (which is passed as the first argument to the local function) ''after'' the user has clicked the button. I'm not exactly sure how this mechanism works, my initial guess is that the popup functions are run in a separate thread to allow for this kind of manipulation. | |||
:[[User:Wickedsick|Wickedsick]] 02:49, 8 May 2006 (EDT) | |||
== Notes and Observations == | == Notes and Observations == | ||