Quantcast
WoWInterface - View Single Post - Looking for lua code example of how to get a button to highlight on push down
View Single Post
08-26-21, 11:45 PM   #1
Zimzarina
A Murloc Raider
Join Date: Aug 2019
Posts: 6
Looking for lua code example of how to get a button to highlight on push down

For an addon I am working on I have created a icon button similar to other profession buttons like cooking and leatherworking. I am able to SetNormalTexture and SetHighlightTexture fine and it looks as expected in those cases. However, when I try to SetPushedTexture, "ADD" I don't get the nice appearance I expect I get basically a transparent button with a edge highlight. What I want is to find an example code of how to create a button that uses the same highlight and pushed button effects that regular ActionBars do. Thanks!

Example code below that shows what I am asking about.

local NewButtonEventFrame, NewButtonEvents, NewButtonFunctionName = CreateFrame("Frame"), {}

function NewButtonEvents:PLAYER_ENTERING_WORLD(isInitialLogin, isReloadingUi)
if not NewButton then
NewButton = CreateFrame("Button", "NewButton", UIParent)
NewButton:SetWidth(40)
NewButton:SetHeight(40)
NewButton:SetPoint("CENTER",0,0)
NewButton:SetNormalTexture("Interface\\Icons\\INV_Misc_ArmorKit_17")
NewButton:SetHighlightTexture("Interface\\Buttons\\ButtonHilight-Square","ADD",0)
NewButton:SetPushedTexture("Interface\\Icons\\INV_Misc_ArmorKit_17")
NewButton:SetPushedTexture("Interface\\Buttons\\UI-Quickslot-Depress","ADD")
NewButton:SetScript("OnClick", function() NewButtonClick() end)
end
if NewButton then NewButton:Show() end
end

function NewButtonClick()
DEFAULT_CHAT_FRAME:AddMessage("Click")
end

NewButtonEventFrame:SetScript("OnEvent", function(self, event, ...)
NewButtonEvents[event](self, ...)
end)
for NewButtonEventName, NewButtonFunctionName in pairs(NewButtonEvents) do
NewButtonEventFrame:RegisterEvent(NewButtonEventName)
end

Last edited by Zimzarina : 08-27-21 at 02:41 PM.
  Reply With Quote