Mercurial > wow > askmrrobot
comparison ui/AmrUiTextButton.lua @ 161:35612aee8e15
Added junk list.
| author | yellowfive |
|---|---|
| date | Mon, 06 May 2019 14:08:03 -0700 |
| parents | a0894ffebd15 |
| children |
comparison
equal
deleted
inserted
replaced
| 160:d670336e8c89 | 161:35612aee8e15 |
|---|---|
| 17 | 17 |
| 18 | 18 |
| 19 --[[----------------------------------------------------------------------------- | 19 --[[----------------------------------------------------------------------------- |
| 20 Scripts | 20 Scripts |
| 21 -------------------------------------------------------------------------------]] | 21 -------------------------------------------------------------------------------]] |
| 22 local function buttonOnClick(frame, ...) | 22 -- to facilitate some use cases, we have click fired on PostClick for this widget |
| 23 --[[local function buttonOnClick(frame, ...) | |
| 23 AceGUI:ClearFocus() | 24 AceGUI:ClearFocus() |
| 24 --PlaySound("igMainMenuOption") | 25 --PlaySound("igMainMenuOption") |
| 26 frame.obj:Fire("OnClick", ...) | |
| 27 end]] | |
| 28 | |
| 29 local function buttonPreClick(frame, ...) | |
| 30 frame.obj:Fire("PreClick", ...) | |
| 31 end | |
| 32 | |
| 33 local function buttonPostClick(frame, ...) | |
| 25 frame.obj:Fire("OnClick", ...) | 34 frame.obj:Fire("OnClick", ...) |
| 26 end | 35 end |
| 27 | 36 |
| 28 local function buttonOnEnter(frame) | 37 local function buttonOnEnter(frame) |
| 29 frame.obj.bg:Hide() | 38 frame.obj.bg:Hide() |
| 179 if visible then | 188 if visible then |
| 180 self.frame:Show() | 189 self.frame:Show() |
| 181 else | 190 else |
| 182 self.frame:Hide() | 191 self.frame:Hide() |
| 183 end | 192 end |
| 193 end, | |
| 194 | |
| 195 -- | |
| 196 -- If text is specified, turns this into a button that calls a macro | |
| 197 -- | |
| 198 ["SetMacroText"] = function(self, text) | |
| 199 if text then | |
| 200 self.frame:SetAttribute("type", "macro") | |
| 201 self.frame:SetAttribute("macrotext", text) | |
| 202 else | |
| 203 self.frame:SetAttribute("type", nil) | |
| 204 self.frame:SetAttribute("macrotext", nil) | |
| 205 end | |
| 184 end | 206 end |
| 185 } | 207 } |
| 186 | 208 |
| 187 --[[----------------------------------------------------------------------------- | 209 --[[----------------------------------------------------------------------------- |
| 188 Constructor | 210 Constructor |
| 189 -------------------------------------------------------------------------------]] | 211 -------------------------------------------------------------------------------]] |
| 190 local function Constructor() | 212 local function Constructor() |
| 191 local name = "AmrUiTextButton" .. AceGUI:GetNextWidgetNum(Type) | 213 local name = "AmrUiTextButton" .. AceGUI:GetNextWidgetNum(Type) |
| 192 local frame = CreateFrame("Button", name, UIParent) | 214 local frame = CreateFrame("Button", name, UIParent, "SecureActionButtonTemplate") |
| 193 frame:Hide() | 215 frame:Hide() |
| 194 | 216 |
| 195 local txt = frame:CreateFontString() | 217 local txt = frame:CreateFontString() |
| 196 frame:SetFontString(txt) | 218 frame:SetFontString(txt) |
| 197 | 219 |
| 199 subtxt:Hide() | 221 subtxt:Hide() |
| 200 | 222 |
| 201 frame:EnableMouse(true) | 223 frame:EnableMouse(true) |
| 202 frame:SetScript("OnEnter", buttonOnEnter) | 224 frame:SetScript("OnEnter", buttonOnEnter) |
| 203 frame:SetScript("OnLeave", buttonOnLeave) | 225 frame:SetScript("OnLeave", buttonOnLeave) |
| 204 frame:SetScript("OnClick", buttonOnClick) | 226 --frame:SetScript("OnClick", buttonOnClick) |
| 227 frame:SetScript("PreClick", buttonPreClick) | |
| 228 frame:SetScript("PostClick", buttonPostClick) | |
| 205 | 229 |
| 206 local bg = frame:CreateTexture() | 230 local bg = frame:CreateTexture() |
| 207 bg:SetAllPoints() | 231 bg:SetAllPoints() |
| 208 | 232 |
| 209 local hover = frame:CreateTexture() | 233 local hover = frame:CreateTexture() |
