12.07.2015 Views

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

Wiley-World.of.Warcraft.Programming.A.Guide.and.Reference.for.Creating.WoW.Addons

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 29 ■ Widget <strong>Reference</strong> 1123HasScriptReturns whether the widget supports a script h<strong>and</strong>ler.hasScript = ScriptObject:HasScript(“scriptType“)Arguments:scriptType—A script type; see scripts reference <strong>for</strong> details (string)Returns:hasScript—1 if the widget can h<strong>and</strong>le the script, otherwise nil (1nil)HookScriptSecurely hooks a script h<strong>and</strong>ler.ScriptObject:HookScript(“scriptType“, h<strong>and</strong>ler)Equivalent to hooksecurefunc() <strong>for</strong> script h<strong>and</strong>lers; allows one to‘‘post-hook’’ a secure h<strong>and</strong>ler without tainting the original.The original h<strong>and</strong>ler will still be called, but the h<strong>and</strong>ler supplied will also becalled after the original, with the same arguments. Return values from thesupplied h<strong>and</strong>ler are discarded. Note that there is no API to remove a hookfrom a h<strong>and</strong>ler: any hooks applied will remain in place until the UI is reloaded.If there was no prior script h<strong>and</strong>ler set, then this simply sets the new functionas the h<strong>and</strong>ler <strong>for</strong> the script type.Arguments:scriptType—Name <strong>of</strong> the script whose h<strong>and</strong>ler should be hooked (string)h<strong>and</strong>ler—A function to be called whenever the script h<strong>and</strong>ler is run(function)Example:-- hooks the default UI’s player frame to insert a chat link to the-- player’s most recently completed achievement when shift-clickedfunction PlayerLink(self, button, down)if ( IsModifiedClick(“CHATLINK“) ) thenlocal link = iGetAchievementLink(select(1,GetLatestCompletedAchievements()))ChatEdit_InsertLink (link)endendPlayerFrame:HookScript(“OnClick“, PlayerLink)SetScriptSets the widget’s h<strong>and</strong>ler function <strong>for</strong> a script.ScriptObject:SetScript(“scriptType“, h<strong>and</strong>ler)Arguments:scriptType—A script type; see scripts <strong>for</strong> details (string)h<strong>and</strong>ler—A function to become the widget’s h<strong>and</strong>ler <strong>for</strong> the script type(function)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!