Frame:SetClampRectInsets

From Warcraft Wiki
Jump to navigation Jump to search

Controls how much of the frame may be moved off-screen.

Frame:SetClampRectInsets(left, right, top, bottom)

Arguments

left
number : uiUnit - Left clamp region offset. Controls collision with the left edge of the screen, positive values allow the frame to be moved off-screen, negative values enforce minimum distance to the edge.
right
number : uiUnit - Right clamp region offset. Controls collision with the right edge of the screen, negative values allow the frame to be moved off-screen, positive values enforce minimum distance to the edge.
top
number : uiUnit - Top clamp region offset. Controls collision with the top edge of the screen, negative values allow the frame to be moved off-screen, positive values enforce minimum distance to the edge.
bottom
number : uiUnit - Bottom clamp region offset. Controls collision with the bottom edge of the screen, positive values allow the frame to be moved off-screen, negative values enforce minimum distance to the edge.

Details

Example

The following code creates a draggable frame that can be moved 42 size units off any edge of the screen, but can never be entirely off-screen.

local f = CreateFrame("Frame", nil, UIParent)
f:SetSize(200, 100)
f:SetPoint("CENTER")
f:SetMovable(true)
f:SetScript("OnMouseDown", f.StartMoving)
f:SetScript("OnMouseUp", f.StopMovingOrSizing)
f:SetClampedToScreen(true)
f:SetClampRectInsets(42, -42, -42, 42)

f.tex = f:CreateTexture()
f.tex:SetColorTexture(1, 0, 0)
f.tex:SetAllPoints()