![]() |
The API is no longer being updated here until further notice. |
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,LeftButtonDownRightButtonUp,RightButtonDownMiddleButtonUp,MiddleButtonDownButton4Up,Button4DownButton5Up,Button5Down
Details[]
- The default button registered on new button objects is
LeftButtonUp. - Pass multiple arguments to register several buttons, or none to remove any previous registrations.
- Subsequent calls replace any prior ones.
- Controls OnClick, PreClick, PostClick, and OnDoubleClick.
- Does not affect OnMouseDown, OnMouseUp, nor OnDragStart.
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.
