Thread Tools Display Modes
08-10-10, 07:44 AM   #1
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post Durability,Ticket Frame

hi there all

i want to be able to move the Durability,Ticket Frame

this is what i did.


Code:
DurabilityFrame:RegisterForDrag("LeftButton")
DurabilityFrame:SetClampedToScreen(true)
DurabilityFrame:SetMovable(true)
DurabilityFrame:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
DurabilityFrame:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
Code:
TicketStatusFrame:RegisterForDrag("LeftButton")
TicketStatusFrame:SetClampedToScreen(true)
TicketStatusFrame:SetMovable(true)
TicketStatusFrame:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
TicketStatusFrame:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)

but it dont seem to work. what am i missing.

i then got to this

Code:
	local mmframe = {
		"TicketStatusFrame",
		"DurabilityFrame",
	}
	for _, mmframe in pairs(self.mmframes) do
		mmframe:RegisterForDrag("LeftButton")
                mmframe:SetClampedToScreen(true)
		mmframe:SetMovable(true)
		mmframe:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
		mmframe:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
	end
a bit tidyer. but this way. im missing somthing.

thanks for your time
  Reply With Quote
08-10-10, 07:53 AM   #2
Guardix
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 42
Originally Posted by weasoug View Post
Code:
local mmframe = {
	"TicketStatusFrame",
	"DurabilityFrame",
}
for _, mmframe in pairs(self.mmframes) do
	mmframe:RegisterForDrag("LeftButton")
        mmframe:SetClampedToScreen(true)
	mmframe:SetMovable(true)
	mmframe:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
	mmframe:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
end
Your table's name is mmframe not mmframes and you shouldn't use self.mmframe, just mmframe.

Also I'm unsure if you need to clear the frame's points when you drag it, but I think you should try it (self:ClearAllPoints()).

edit: You don't need to clear the points, but remember to enable the mouse. mmframe:EnableMouse(true)
__________________

Last edited by Guardix : 08-10-10 at 07:58 AM.
  Reply With Quote
08-10-10, 08:08 AM   #3
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post

Originally Posted by Guardix View Post
Your table's name is mmframe not mmframes and you shouldn't use self.mmframe, just mmframe.

Also I'm unsure if you need to clear the frame's points when you drag it, but I think you should try it (self:ClearAllPoints()).

edit: You don't need to clear the points, but remember to enable the mouse. mmframe:EnableMouse(true)
so like


Code:
local mmframe = {
	"TicketStatusFrame",
	"DurabilityFrame",
}
for _, mmframe in pairs(mmframe) do
        mmframe:EnableMouse(true)
	mmframe:RegisterForDrag("LeftButton")
        mmframe:SetClampedToScreen(true)
	mmframe:SetMovable(true)
	mmframe:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
	mmframe:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
end
not sure where to use this.

(self:ClearAllPoints()).

tryed a few things but i get errors./
  Reply With Quote
08-10-10, 08:24 AM   #4
Mischback
A Cobalt Mageweaver
 
Mischback's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 221
lua Code:
  1. local mmframe = {
  2.     "TicketStatusFrame",
  3.     "DurabilityFrame",
  4. }
  5. for _, item in pairs(mmframe) do
  6.         item:EnableMouse(true)
  7.     item:RegisterForDrag("LeftButton")
  8.         item:SetClampedToScreen(true)
  9.     item:SetMovable(true)
  10.     item:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
  11.     item:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
  12. end

I think it's a bad idea to use the same variable-name more than one time for different purposes!
__________________
  Reply With Quote
08-10-10, 08:33 AM   #5
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post

Originally Posted by Mischback View Post
lua Code:
  1. local mmframe = {
  2.     "TicketStatusFrame",
  3.     "DurabilityFrame",
  4. }
  5. for _, item in pairs(mmframe) do
  6.         item:EnableMouse(true)
  7.     item:RegisterForDrag("LeftButton")
  8.         item:SetClampedToScreen(true)
  9.     item:SetMovable(true)
  10.     item:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
  11.     item:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
  12. end

I think it's a bad idea to use the same variable-name more than one time for different purposes!
i see. but it dont like

item:EnableMouse(true)

is it part of
:SetUserPlaced(true)

edit--
i get
attempt to call method

so do i need to local item with frame like

local item = CreateFrame("frame")

and or a SetPoint .

Last edited by weasoug : 08-10-10 at 08:40 AM.
  Reply With Quote
08-10-10, 09:16 AM   #6
Guardix
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 42
Originally Posted by weasoug View Post
i see. but it dont like

item:EnableMouse(true)

is it part of
:SetUserPlaced(true)

edit--
i get
attempt to call method

so do i need to local item with frame like

local item = CreateFrame("frame")

and or a SetPoint .
EnableMouse is to make the frame solid, so your mouse clicks dont go through to the worldframe. Could you try doing the commands in game, perhaps the frames aren't created when you call those functions when your addon loads.
In-game do:
Code:
/run DurabilityFrame:EnableMouse(true)
/run DurabilityFrame:RegisterForDrag("LeftButton")
/run DurabilityFrame:SetClampedToScreen(true)
/run DurabilityFrame:SetMovable(true)
/run DurabilityFrame:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
/run DurabilityFrame:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
That works for me at least.
__________________
  Reply With Quote
08-10-10, 09:22 AM   #7
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post

Originally Posted by Guardix View Post
EnableMouse is to make the frame solid, so your mouse clicks dont go through to the worldframe. Could you try doing the commands in game, perhaps the frames aren't created when you call those functions when your addon loads.
In-game do:
Code:
/run DurabilityFrame:EnableMouse(true)
/run DurabilityFrame:RegisterForDrag("LeftButton")
/run DurabilityFrame:SetClampedToScreen(true)
/run DurabilityFrame:SetMovable(true)
/run DurabilityFrame:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
/run DurabilityFrame:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
That works for me at least.
yes i id that before you said. and all is working fine.

its this part

local mmframe = {
"TicketStatusFrame",
"DurabilityFrame",
}
for _, item in pairs(mmframe) do
item:EnableMouse(true)
ect

item should call mmframe and do
DurabilityFrame:EnableMouse(true)

but
item:EnableMouse(true)

but it seems to not be calling it.
  Reply With Quote
08-10-10, 09:25 AM   #8
Guardix
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 42
Originally Posted by weasoug View Post
yes i id that before you said. and all is working fine.

its this part

local mmframe = {
"TicketStatusFrame",
"DurabilityFrame",
}
for _, item in pairs(mmframe) do
item:EnableMouse(true)
ect

item should call mmframe and do
DurabilityFrame:EnableMouse(true)

but
item:EnableMouse(true)

but it seems to not be calling it.
Aha, make it say this instead:
Code:
local mmframe = {
    _G["TicketStatusFrame"],
    _G["DurabilityFrame"],
}
__________________
  Reply With Quote
08-10-10, 12:08 PM   #9
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post

Originally Posted by Guardix View Post
Aha, make it say this instead:
Code:
local mmframe = {
    _G["TicketStatusFrame"],
    _G["DurabilityFrame"],
}
that worked well.


now trying to do a lock and unlock

Code:
SlashCmdList["test"] = function(arg1)
	if arg1:lower() == "unlock" then
		mmframe:Show()
                print(wname.."|cFF00FFFF: unlocked for drag.|r")
SLASH_test1 = "/te"
  Reply With Quote
08-10-10, 12:24 PM   #10
Guardix
A Cyclonian
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 42
Originally Posted by weasoug View Post
that worked well.


now trying to do a lock and unlock

Code:
SlashCmdList["test"] = function(arg1)
	if arg1:lower() == "unlock" then
		mmframe:Show()
                print(wname.."|cFF00FFFF: unlocked for drag.|r")
SLASH_test1 = "/te"
Code:
SlashCmdList["test"] = function(arg1)
	if arg1:lower() == "unlock" then
		for _, frame in next, mmframe do
			frame:SetMovable(true)
		end
                print(wname.."|cFF00FFFF: unlocked for drag.|r")
	elseif arg1:lower() == "lock" then
		for _, frame in next, mmframe do
			frame:SetMovable(false)
		end
		print(wname.."|cFF00FFFF: locked for drag.|r")
	else
		print(wname..": Invalid command.")
	end
end
that next part is basically what pairs() do.
__________________

Last edited by Guardix : 08-10-10 at 12:27 PM.
  Reply With Quote
08-10-10, 01:09 PM   #11
weasoug
A Flamescale Wyrmkin
 
weasoug's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 127
Post

to Guardix. ace work there. simple. but was ace.
i did think to start with that it might be to do with
for _, item in pairs(mmframe) do

but could work out what to do. hehe.

ok i got every thing working ok. all thats bugging me is its not saving where i place them, this makes me think its due to the _G

as when i used

Code:
DurabilityFrame:EnableMouse(true)
DurabilityFrame:RegisterForDrag("LeftButton")
DurabilityFrame:SetClampedToScreen(true)
DurabilityFrame:SetMovable(true)
DurabilityFrame:SetScript("OnDragStart", function(self) if IsAltKeyDown() then self:StartMoving() end end)
DurabilityFrame:SetScript("OnDragStop", function(self) if IsAltKeyDown() then self:StopMovingOrSizing() end end)
when i /reload the ui. its in the place i left it.

but with this code it dont

Code:
local mmframe = {
    _G["TicketStatusFrame"],
    _G["DurabilityFrame"],
    _G["Minimap"],
}
for _, item in pairs(mmframe) do
	item:SetScript("OnDragStart", item.StartMoving)
	item:SetScript("OnDragStop", item.StopMovingOrSizing)
end


SlashCmdList["test"] = function(arg1)
	if arg1:lower() == "unlock" then
		for _, item in next, mmframe do
			item:SetMovable(true)
                        item:EnableMouse(true)
        item:RegisterForDrag("LeftButton")
        item:SetClampedToScreen(true)
		end
                print(wname.."|cFF00FFFF: unlocked for drag.|r")
	elseif arg1:lower() == "lock" then
		for _, item in next, mmframe do
			item:SetMovable(false)
                        item:EnableMouse(false)
        item:SetClampedToScreen(false)
		end
		print(wname.."|cFF00FFFF: locked for drag.|r")
	else
		print(wname..": Invalid command.")
	end
end
and the bad thing with item:EnableMouse(false) is that you can use the left mouse button on the minimap.

as well as i still cant work out how to keep the place i left them in.

Last edited by weasoug : 08-10-10 at 04:52 PM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Durability,Ticket 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