Navigation menu

WoW:USEROBJECT MenuClass: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
m (New page: {{userfunc}} <!-- Leave this line in! --> Create a drop down menu at your leisure and show it when you're ready. == Usage == <pre>local menu = MenuClass:New() menu:AddItem('Do Something',...)
 
mNo edit summary
Line 1: Line 1:
{{userfunc}} <!-- Leave this line in! -->
{{usermodule|MenuClass}}
Create a drop down menu at your leisure and show it when you're ready. This is a very basic context menu, nothing advanced.
Create a drop down menu at your leisure and show it when you're ready. This is a very basic context menu, nothing advanced.


Line 17: Line 17:


== Properties ==
== Properties ==
;.menuItems : Table. Stores the menu items.
;.menuItems
;.anchor : String. The anchor.
: Table. Stores the menu items.
;.x : The x offset
;.anchor
;.y : The y offset
: String. The anchor.
;.displayMode : The display mode.
;.x
;.autoHideDelay : The time it takes for the menu to automatically hide.
: The x offset
;.menuFrame : The menu frame.
;.y
;.uniqueID : A self incrementing number used to ensure that the generic menu frame is unique.
: The y offset
;.isTitle : Is this menu item a header? 1 if yes, nil if no.
;.displayMode
: The display mode.
;.autoHideDelay
: The time it takes for the menu to automatically hide.
;.menuFrame
: The menu frame.
;.uniqueID
: A self incrementing number used to ensure that the generic menu frame is unique.
;.isTitle
: Is this menu item a header? 1 if yes, nil if no.


== Methods ==
== Methods ==
;&#58;Activate() : Creates the menu frame if it has not already been set with :SetMenuFrame().
;&#58;Activate()
;&#58;AddItem(<string> text, <function> func, <number> isTitle) : Add a menu item with ''text'' text that does ''func''. Requires at least 1.
: Creates the menu frame if it has not already been set with :SetMenuFrame().
;&#58;GetAttribute(<string|number> text, <string|number> attribute) : Gets an attribute for the given menu item.
;&#58;AddItem(<string> text, <function> func, <number> isTitle)
;&#58;New() : Allocate memory for the new menu and set the defaults. Required. Returns the menu.
: Add a menu item with ''text'' text that does ''func''. Requires at least 1.
;&#58;RemoveItem(<string> text) : Remove the first menu item that matches ''text''
;&#58;GetAttribute(<string|number> text, <string|number> attribute)
;&#58;SetAnchor(<string> anchor) : Set the ''anchor''. Optional. Default: "cursor"
: Gets an attribute for the given menu item.
;&#58;SetAttribute(<string|number> text, <string|number> attribute, <string|number> value) : Sets an attribute for the given menu item.
;&#58;New()
;&#58;SetDisplayMode(<string> displayMode) : Set the ''displayMode''. Optional. Default: "MENU"
: Allocate memory for the new menu and set the defaults. Required. Returns the menu.
;&#58;SetAutoHideDelay(<number> autoHideDelay) : Set the ''autoHideDelay''. Optional. Default: nil (does not auto close)
;&#58;RemoveItem(<string> text)
;&#58;SetMenuFrame(<menuFrame> menuFrame) : Set the ''menuFrame''. Optional. Default: self generating menuFrame. If set, this must be a frame that inherits '''UIDropDownMenuTemplate'''.
: Remove the first menu item that matches ''text''
;&#58;SetX(<number> x[, <boolean> save]) : Set the ''x'' offset. Optional. Default: nil (0 if ''anchor'' is not "cursor"). If save resolves to true, ''x'' will be added to rather than replaced.
;&#58;SetAnchor(<string> anchor)
;&#58;SetY(<number> y[, <boolean> save]) : Set the ''y'' offset. Optional. Default: nil (0 if ''anchor'' is not "cursor"). If save resolves to true, ''y'' will be added to rather than replaced.
: Set the ''anchor''. Optional. Default: "cursor"
;&#58;Show() : Show the menu.
;&#58;SetAttribute(<string|number> text, <string|number> attribute, <string|number> value)
: Sets an attribute for the given menu item.
;&#58;SetDisplayMode(<string> displayMode)
: Set the ''displayMode''. Optional. Default: "MENU"
;&#58;SetAutoHideDelay(<number> autoHideDelay)
: Set the ''autoHideDelay''. Optional. Default: nil (does not auto close)
;&#58;SetMenuFrame(<menuFrame> menuFrame)
: Set the ''menuFrame''. Optional. Default: self generating menuFrame. If set, this must be a frame that inherits '''UIDropDownMenuTemplate'''.
;&#58;SetX(<number> x[, <boolean> save])
: Set the ''x'' offset. Optional. Default: nil (0 if ''anchor'' is not "cursor"). If save resolves to true, ''x'' will be added to rather than replaced.
;&#58;SetY(<number> y[, <boolean> save])
: Set the ''y'' offset. Optional. Default: nil (0 if ''anchor'' is not "cursor"). If save resolves to true, ''y'' will be added to rather than replaced.
;&#58;Show()
: Show the menu.


== Code ==
== Code ==