WoW:SecureUnitButtonTemplate: Difference between revisions
(menufunc parameters?) |
m (Move page script moved page SecureUnitButtonTemplate to SecureUnitButtonTemplate without leaving a redirect) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{uitech}} | {{uitech}} | ||
'''SecureUnitButtonTemplate''' is one of the SecureTemplates introduced in | '''SecureUnitButtonTemplate''' is one of the SecureTemplates introduced in Patch 2.0. It's purpose is to allow creation of unit frames, executing certain protected actions from secure code in response to clicks. | ||
This template's behavior differs only slightly from [[SecureActionButtonTemplate]], and can be thought of as a special case. The only difference is in how the menu function is handled: the template allows spells currently being targeted to be cancelled before calling the menu function. | This template's behavior differs only slightly from [[SecureActionButtonTemplate]], and can be thought of as a special case. The only difference is in how the menu function is handled: the template allows spells currently being targeted to be cancelled before calling the menu function. | ||
Line 10: | Line 10: | ||
:; unit : String - unit this unit frame is showing/acting on. | :; unit : String - unit this unit frame is showing/acting on. | ||
:; menuFunc : Function - menu function to show when the frame is right clicked. | :; menuFunc : Function - menu function to show when the frame is right clicked. | ||
The function sets a limited number of attributes on a frame to make it behave like the default unit frames: left clicks target the unit, and right clicks open the menu by calling menuFunc | The function sets a limited number of attributes on a frame to make it behave like the default unit frames: left clicks target the unit, and right clicks open the menu by calling menuFunc(self, unit, button). | ||
Latest revision as of 04:48, 15 August 2023
SecureUnitButtonTemplate is one of the SecureTemplates introduced in Patch 2.0. It's purpose is to allow creation of unit frames, executing certain protected actions from secure code in response to clicks.
This template's behavior differs only slightly from SecureActionButtonTemplate, and can be thought of as a special case. The only difference is in how the menu function is handled: the template allows spells currently being targeted to be cancelled before calling the menu function.
Supporting API[edit]
FrameXML defines a convenience method to interact with this template: SecureUnitButton_OnLoad(self, unit, menufunc)
- self
- Frame - frame inheriting from SecureUnitButtonTemplate.
- unit
- String - unit this unit frame is showing/acting on.
- menuFunc
- Function - menu function to show when the frame is right clicked.
The function sets a limited number of attributes on a frame to make it behave like the default unit frames: left clicks target the unit, and right clicks open the menu by calling menuFunc(self, unit, button).
Another useful function is RegisterUnitWatch(frame), which controls the visibility of a protected frame based on whether the unit specified by the frame's "unit" attribute exists.
Supported Attributes[edit]
The template supports all of the attributes supported by SecureActionButtonTemplate, and behaves in similar fashion. There is a single special case: if the value of the modified attribute "type" is "menu" (with no unit remapping performed), the OnClick cancels any spell being targeted and calls menuFunc().
Some attributes may be used to enable automatic vehicle unit remapping for the frame: making the player frame behave as a vehicle frame, and a pet frame behave as a player frame when the player is in a vehicle.
|