Originally Posted by Fizzlemizz
You don't want to actually drag the buttons themselves, you want to activate the container frame onDragxxx
Code:
btn:RegisterForDrag("LeftButton");-- Register for left drag
btn:SetScript("OnDragStart", function(self)
local f = frame:GetScript("OnDragStart") -- Get the frame OnDragStart script
f(frame) -- run it
end);
btn:SetScript("OnDragStop", function(self)
local f = frame:GetScript("OnDragStop") -- Get the frame OnDragStop script
f(frame) -- run it
end);
This requires that the frame creation be above the CeateButton function ie. at the top of the file.
|
I not sure what I'm to change (which parts and where in the code). I think here:
Lua Code:
-- Register handlers
btn:RegisterForClicks("AnyUp");-- Register all buttons
btn:RegisterForDrag("LeftButton");-- Register for left drag
btn:SetScript("OnDragStart",OnDragStart);
btn:SetScript("OnDragStop",OnDragStop);
btn:SetScript("OnEnter",OnEnter);
btn:SetScript("OnLeave",OnLeave);
btn.Tooltip=tooltip;
btn:SetClampedToScreen(enable);
While also moving
Lua Code:
local frame = CreateFrame("Frame","ACFrame",UIParent)
frame:SetPoint("CENTER",UIParent)
frame:SetSize(40+40+20,(7*40)+20)
frame:SetBackdrop(StaticPopup1:GetBackdrop())
frame:SetScale(0.8)
frame:SetMovable(true)
frame:RegisterForDrag("LeftButton")-- Register left button for dragging
frame:SetScript("OnDragStart",frame.StartMoving)-- Set script for drag start
frame:SetScript("OnDragStop",frame.StopMovingOrSizing)-- Set script for drag stop
to the Top. Sorry for asking, I should just do it and see what happens really.
With the current code the frame and buttons all move together when dragging on one of the buttons. Feels nice and easy. I suppose if the player, in the heat of battle, could move the frame by accident. On the other hand it's easier to move without having the click the small area which is the frame.
On another matter.
I'm looking into having the frame only show in Ashran, similar to AshranBuddy.
I'm guessing I'm looking for something like
Fragment Lua from AshranBuddy Code:
if (not Api:IsInAshran()) then
self.Component:Hide()
end
although I'm also looking around
http://wowprogramming.com/ for something useful.
note to self, should remember to load a char which is actually in Ashran for testing this.