The API is no longer being updated here until further notice. |
Invoked when a mouse button is pressed down on a widget.
ScriptRegion OnMouseDown(self, button)
Arguments[]
- self
- ScriptObject - The widget receiving the mouse input
- button
- string :
LeftButton, RightButton, MiddleButton, Button4, Button5
Example[]
Prints when the mouse hovers and clicks the frame.
local f = CreateFrame("Frame", nil, nil, "BackdropTemplate")
f:SetPoint("CENTER")
f:SetSize(200, 200)
f:SetBackdrop(BACKDROP_TUTORIAL_16_16)
f:SetScript("OnEnter", function(self, motion) print("OnEnter", motion) end)
f:SetScript("OnLeave", function(self, motion) print("OnLeave", motion) end)
f:SetScript("OnMouseDown", function(self, button) print("OnMouseDown", button) end)
f:SetScript("OnMouseUp", function(self, button) print("OnMouseUp", button) end)
--f:EnableMouse(false) -- disables mouse interaction
Details[]
Setting the OnMouseDown script automatically implies EnableMouse(true)
local f = CreateFrame("Frame")
print(f:IsMouseEnabled()) -- false
f:SetScript("OnMouseDown", function() end)
print(f:IsMouseEnabled()) -- true