ScriptRegion:EnableMouse

From Warcraft Wiki
Jump to navigation Jump to search

Sets whether the region should receive mouse input.

ScriptRegion:EnableMouse([enable])

Arguments

enable
boolean? = false

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 OnEnter/Leave, OnMouseDown/Up script automatically implies EnableMouse(true)

local f = CreateFrame("Frame")
print(f:IsMouseEnabled()) -- false
f:SetScript("OnMouseDown", function() end)
print(f:IsMouseEnabled()) -- true


In turn, EnableMouse implies SetMouseMotionEnabled and SetMouseClickEnabled

local f = CreateFrame("Frame")
print(f:IsMouseEnabled(), f:IsMouseMotionEnabled(), f:IsMouseClickEnabled()) -- false, false, false
f:EnableMouse(true)
print(f:IsMouseEnabled(), f:IsMouseMotionEnabled(), f:IsMouseClickEnabled()) -- true, true, true