49
edits
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: | ||
{{ | {{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 == | ||
;:Activate() : Creates the menu frame if it has not already been set with :SetMenuFrame(). | ;:Activate() | ||
;: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(). | ||
;:GetAttribute(<string|number> text, <string|number> attribute) : Gets an attribute for the given menu item. | ;:AddItem(<string> text, <function> func, <number> isTitle) | ||
;: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. | ||
;:RemoveItem(<string> text) : Remove the first menu item that matches ''text'' | ;:GetAttribute(<string|number> text, <string|number> attribute) | ||
;:SetAnchor(<string> anchor) : Set the ''anchor''. Optional. Default: "cursor" | : Gets an attribute for the given menu item. | ||
;:SetAttribute(<string|number> text, <string|number> attribute, <string|number> value) : Sets an attribute for the given menu item. | ;:New() | ||
;:SetDisplayMode(<string> displayMode) : Set the ''displayMode''. Optional. Default: "MENU" | : Allocate memory for the new menu and set the defaults. Required. Returns the menu. | ||
;:SetAutoHideDelay(<number> autoHideDelay) : Set the ''autoHideDelay''. Optional. Default: nil (does not auto close) | ;:RemoveItem(<string> text) | ||
;: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'' | ||
;: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. | ;:SetAnchor(<string> anchor) | ||
;: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" | ||
;:Show() : Show the menu. | ;:SetAttribute(<string|number> text, <string|number> attribute, <string|number> value) | ||
: Sets an attribute for the given menu item. | |||
;:SetDisplayMode(<string> displayMode) | |||
: Set the ''displayMode''. Optional. Default: "MENU" | |||
;:SetAutoHideDelay(<number> autoHideDelay) | |||
: Set the ''autoHideDelay''. Optional. Default: nil (does not auto close) | |||
;:SetMenuFrame(<menuFrame> menuFrame) | |||
: Set the ''menuFrame''. Optional. Default: self generating menuFrame. If set, this must be a frame that inherits '''UIDropDownMenuTemplate'''. | |||
;: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. | |||
;: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. | |||
;:Show() | |||
: Show the menu. | |||
== Code == | == Code == | ||