Wowpedia
Advertisement

Called when the user presses a mouse button overtop a mouse-enabled Frame.

(self, button)

Arguments

self 
Frame - The widget on which the mouse button was pressed.
button 
string - "LeftButton", "RightButton", "MiddleButton", "Button4", "Button5", ..., "ButtonN"

Details

Examples

local frame = CreateFrame("Button", nil, UIParent)
frame:SetSize(100, 100)
frame:SetPoint("CENTER")

frame:SetScript("OnMouseDown", function (self, button)
	print("Pressed " .. button)
end)

frame:SetScript("OnMouseUp", function (self, button)
	print("Pressed and released " .. button)
end)

local texture = frame:CreateTexture("BACKGROUND")
texture:SetAllPoints()
texture:SetColorTexture(1,1,1)

See also

  • OnMouseUp - Called when the user later releases the mouse button, even if dragged elsewhere.
  • OnClick - Alternative specific to the Button widget type.
Advertisement