WoW:XML/Script: Difference between revisions

From AddOn Studio
< XML
Jump to navigation Jump to search
(Created page with "{{uixmltype}} Script is way to add handler code to a UI element. Script is base type that is not used directly, but added to <Scripts> using on...")
 
Line 14: Line 14:


== Attributes ==
== Attributes ==
* inherit ([[XML types#SCRIPTINHERITTYPE|SCRIPTINHERITTYPE]]) (optional) - order to run this script relative to any inherited scripts. Default is 'none'.
* function {{attrtype|string}} (optional) - global name of function to call, in lieu of inline text.
* function {{attrtype|string}} (optional) - global name of function to call, in lieu of inline text.
* method {{attrtype|string}} (optional) - this frame Lua object or 'mixin' name of function to call, in lieu of inline text.
* inherit ([[XML types#SCRIPTINHERITTYPE|SCRIPTINHERITTYPE]]) (optional) - order to run this script relative to any inherited scripts for this event. Default is 'none'.
* intrinsicOrder ([[XML types#SCRIPTINTRINSICORDERTYPE|SCRIPTINTRINSICORDERTYPE]]) (optional) - order to run this script relative to any implementation scripts for this event. Default is 'none'. Used only in an intrinsic definition.
== Xsd ==
<xs:complexType name="ScriptType">
  <xs:simpleContent>
    <xs:extension base="xs:string">
      <xs:attribute name="function" type="xs:string"/>
      <xs:attribute name="method" type="xs:string"/><!-- new after 7.1 -->
      <xs:attribute name="inherit" type="SCRIPTINHERITTYPE" use="optional" default="none"/>
      <xs:attribute name="intrinsicOrder" type="SCRIPTINTRINSICORDERTYPE" use="optional" default="none"/><!-- new after 7.1 -->
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>


== Summary ==
== Summary ==

Revision as of 02:40, 28 November 2020

XML UI ← XML types < Script

Script is way to add handler code to a UI element. Script is base type that is not used directly, but added to <Scripts> using one of the specific handler types such as 'OnClick'. The Script type provides a base type for all of the hander types.

Inheritance

Inherited by: OnClick, OnEnter, OnLoad, OnEvent ..., Inherits: none, Defined in: Scripts Runtime object: UIOBJECT_Script

Elements

none

Payload

  • (optional) - Lua script as plain text.

Attributes

  • function (string) (optional) - global name of function to call, in lieu of inline text.
  • method (string) (optional) - this frame Lua object or 'mixin' name of function to call, in lieu of inline text.
  • inherit (SCRIPTINHERITTYPE) (optional) - order to run this script relative to any inherited scripts for this event. Default is 'none'.
  • intrinsicOrder (SCRIPTINTRINSICORDERTYPE) (optional) - order to run this script relative to any implementation scripts for this event. Default is 'none'. Used only in an intrinsic definition.

Xsd

<xs:complexType name="ScriptType">
  <xs:simpleContent>
    <xs:extension base="xs:string">
      <xs:attribute name="function" type="xs:string"/>
      <xs:attribute name="method" type="xs:string"/>
      <xs:attribute name="inherit" type="SCRIPTINHERITTYPE" use="optional" default="none"/>
      <xs:attribute name="intrinsicOrder" type="SCRIPTINTRINSICORDERTYPE" use="optional" default="none"/>
    </xs:extension>
  </xs:simpleContent>
</xs:complexType>

Summary

Script based elements facilitate frame and other elements event handler mechanisms for the WoW UI at runtime. Allows WoW to run UI Lua code at runtime each frame and during startup. Without this general mechanism, only the global file-level Lua code during initial load would be able to run. So this is WoW's predominate way of calling into the Lua UI code form the regular client "C" code.

Example

<Frame name="MyFrameTemplate" hidden="true" virtual="true"/>
<Frame name="MyFrame" inherts="MyFrameTemplate">
  <Size x="400" y="400"/>
  <Frames>
    <Frame name="$parentChild" parentKey="child">
      <Size x="200" y="100"/>
      <Scripts>
        <OnMouseUp>
          print(self:GetName(),"clicked")
        </OnMouseUp>
      </Scripts>
    </Frame>
  </Frames>
</Frame>

This example will align the top of the 'child' frame to the top of 'MyFrame', and print "clicked" on the chat window when the user's mouse button goes 'up' over the child frame.

See also