Wowpedia

We have moved to Warcraft Wiki. Click here for information and the new URL.

READ MORE

Wowpedia

Registers the button widget to receive mouse clicks.

Button:RegisterForClicks([button1, ...])

Arguments[]

button1, ...
string? - A list of combinations of mouse buttons and their click action.
AnyUp - Responds to the up action of any mouse button.
AnyDown - Responds to the down action of any mouse button.
LeftButtonUp, LeftButtonDown
RightButtonUp, RightButtonDown
MiddleButtonUp, MiddleButtonDown
Button4Up, Button4Down
Button5Up, Button5Down

Details[]

Example[]

local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
btn:SetPoint("CENTER")
btn:SetSize(100, 40)
btn:SetText("Click me")
btn:RegisterForClicks("AnyDown", "AnyUp")

-- only the OnClick script is affected by RegisterForClicks
btn:SetScript("OnClick", function(self, button, down)
	print("OnClick", button, down)
end)

btn:SetScript("OnMouseDown", function(self, button)
	print("OnMouseDown", button)
end)

btn:SetScript("OnMouseUp", function(self, button)
	print("OnMouseUp", button)
end)

When clicking with the left mouse button.

API Button RegisterForClicks 02