Thread Tools Display Modes
Prev Previous Post   Next Post Next
01-24-14, 05:12 AM   #1
Resike
A Pyroguard Emberseer
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,290
Resize frame

I would like to resize a frame with the mouse, just like the chat frame resizing, however i don't want anything fancy i just want to increase and decrase the scale of the frame based on the mouse's position. Here is my code so far:

Lua Code:
  1. local function LeftButtonOnUpdate(frame, elapsed)
  2.     --frame.x = math.floor(frame:GetLeft() + (frame:GetWidth() - UIParent:GetWidth()) / 2 + 0.5)
  3.     --frame.y = math.floor(frame:GetTop() - (frame:GetHeight() + UIParent:GetHeight()) / 2 + 0.5)
  4.     FRAMETORESIZE:SetScale(FRAMETORESIZE:GetScale() * 1.001)
  5. end
  6.  
  7. local function SizeOnMouseDown(frame, button)
  8.     if button == "LeftButton" then
  9.         frame.x, frame.y = GetCursorPosition()
  10.         frame:SetScript("OnUpdate", LeftButtonOnUpdate)
  11.     end
  12. end
  13.  
  14. local function SizeOnMouseUp(frame, button)
  15.     if button == "LeftButton" then
  16.         frame:SetScript("OnUpdate", nil)
  17.     end
  18. end
  19.  
  20. function ResizeStart(frame)
  21.     frame:SetScript("OnMouseDown", SizeOnMouseDown)
  22.     frame:SetScript("OnMouseUp", SizeOnMouseUp)
  23. end

Last edited by Resike : 01-24-14 at 05:17 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » Resize frame


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off