View Single Post
02-12-16, 03:45 PM   #13
tyroneexe
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Feb 2016
Posts: 13
Originally Posted by SDPhantom View Post
PS: Don't forget to add the Frame:SetMovable(true) that I forgot earlier, otherwise the container frame won't run the OnDrag* scripts.
It is in there as far as I can see.

I tried adding Frame:SetClampedToScreen(enable), but it just returned an error.

Lua Code:
  1. Frame:SetClampedToScreen(enable) --True to limit the frame's boundaries to those of the screen; false to allow the frame to be moved/resized without such limits

I instead added
Lua Code:
  1. btn:SetClampedToScreen(enable);
to
Lua Code:
  1. --      Register handlers
  2.         btn:RegisterForClicks("AnyUp");--   Register all buttons
  3.         btn:RegisterForDrag("LeftButton");--    Register for left drag
  4.         btn:SetScript("OnDragStart",OnDragStart);
  5.         btn:SetScript("OnDragStop",OnDragStop);
  6.         btn:SetScript("OnEnter",OnEnter);
  7.         btn:SetScript("OnLeave",OnLeave);
  8.         btn.Tooltip=tooltip;
  9.         btn:SetClampedToScreen(enable);

which does the job. As far as I can tell it works on the button which the mouse is interacting with, meaning that button cannot be moved out of the screen, but the others can. Since you can then still drag the entire frame back, I suppose that it good enough.

You might have a point about the ability to resize. Set scale to 0.8 for now
Lua Code:
  1. frame:SetScale(0.8)
  Reply With Quote