View Single Post
10-04-19, 09:47 AM   #1
Zax
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 147
Button to dynamically resize a parent frame?

Hello,

I'm trying to make a handler in the bottom right of a main frame in order to dynamically resize this frame and its contents.
With the following script, only the main frame is resized, not its content (all its children, like subframes, buttons, etc).
I guess I forgot something important...
Code:
frame:SetClampedToScreen(true)
frame:SetMovable(true)
frame:SetUserPlaced(true)
frame:SetResizable(true)
frame:SetMaxResize(frame.width * 1.5, frame.height * 1.5)
frame:SetMinResize(frame.width / 1.5, frame.height / 1.5)

local handlerBtn = CreateFrame("Button", "$parent_handler", frame)
handlerBtn:SetSize(16, 16)
handlerBtn:SetPoint("TOPLEFT", frame, "BOTTOMRIGHT", -16, 16)
local texture = handlerBtn:CreateTexture(nil,"BACKGROUND")
texture:SetAllPoints(true)
texture:SetColorTexture(1, 0, 0, 0.6)
handlerBtn.texture = texture

handlerBtn:EnableMouse(true)
handlerBtn:SetScript("OnMouseDown", function(self, mouse)
	if (mouse == "LeftButton" and not frame.isResizing) then
		self:GetParent().isResizing = true;
		self:GetParent():StartSizing("BOTTOMRIGHT")
	end
end)
handlerBtn:SetScript("OnMouseUp", function(self, mouse)
	if (mouse == "LeftButton" and frame.isResizing) then
		self:GetParent():StopMovingOrSizing()
		self:GetParent().isResizing = false
	end
end)
Thank you.
  Reply With Quote