View Single Post
07-15-13, 07:04 PM   #14
Yksrep
A Fallenroot Satyr
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 21
Im getting a bug that I cant work out. When I first open the addon the scroll frames appear to be working fine, however on subsequent openings there is a bug with the scroll frames. Can someone help me with this.

I have uploaded the full addon to http://www.curseforge.com/media/file.../MapandNav.zip



Main.lua
Code:
-- -- -- -- -- MapandNavStartMenu -- -- -- -- --
local frame = CreateFrame("Frame","MapandNavStartMenu" ,UIParent)
frame:SetWidth(500) -- Set these to whatever height/width is needed 
frame:SetHeight(300) -- for your Texture

local frametexture = frame:CreateTexture(nil,"BACKGROUND")
frametexture:SetTexture("Interface\\AddOns\\MapandNav\\Art\\Background.tga")
frametexture:SetAllPoints(frame)
frame.texture = frametexture
frame:SetPoint("CENTER",0,0)
frame:Hide()
frame:SetScript("OnKeyDown", 
							function(self, Escape, ...)				
							MapandNavStartMenu:Hide()							
							MapandNavFindscrollparentframe:Hide()
							MapandNavscrollframe:Hide()
							MapandNavcontentframe:Hide()
							MapandNavFindtabelperantframe:Hide()
							MapandNavFindtabelperantframe:SetParent(nil)
							MapandNavCitySelecttabelperantframe:Hide()
							MapandNavCitySelecttabelperantframe:SetParent(nil)
							end) 
							
-- -- -- -- -- MapandNavStartButton -- -- -- -- --
local button = CreateFrame("Button", "MapandNavStartButton", UIParent, "UIPanelButtonTemplate")
button:SetText("Start")
button:SetPoint("TOP",0,0)
button:SetWidth(120)
button:SetHeight(50)
button:RegisterForClicks("AnyUp")
button:SetScript("OnClick", 
				function (self, button, down)
				if 
				MapandNavStartMenu:IsVisible() 
				then 
				MapandNavStartMenu:Hide()

				else
				MapandNavStartMenu:Show()
				MapandNavFindButton:Show()
				MapandNavExploreButton:Show()
				end
				end)

-- -- -- -- -- MapandNavStartCloseButton -- -- -- -- --
local button = CreateFrame("button", "MapandNavStartCloseButton", MapandNavStartMenu, "UIPanelCloseButton")
button:SetPoint("TOPRight",-15,-25)
button:SetWidth(40)
button:SetHeight(40)
button:RegisterForClicks("AnyUp")
button:SetScript("OnClick", 
				function (self, button, down)				
							MapandNavStartMenu:Hide()							
							MapandNavFindscrollparentframe:Hide()
							MapandNavscrollframe:Hide()
							MapandNavcontentframe:Hide()
							MapandNavFindtabelperantframe:Hide()
							MapandNavFindtabelperantframe:SetParent(nil)
							MapandNavCitySelecttabelperantframe:Hide()
							MapandNavCitySelecttabelperantframe:SetParent(nil)				
				end)
				
-- -- -- -- -- MapandNavFindButton -- -- -- -- --
local button = CreateFrame("Button", "MapandNavFindButton", MapandNavStartMenu, "UIPanelButtonTemplate")
button:SetText("Find")
button:SetPoint("LEFT", 50,0)
button:SetWidth(180)
button:SetHeight(180)
button:RegisterForClicks("AnyUp")
button:SetScript("OnClick", 
				function (self, button, down)
				MapandNavExploreButton:Hide()
				MapandNavFindButton:Hide()
				MapandNavFindscrollparentframe:Show()
				MapandNavFindtabelperantframe:Show()
				MapandNavscrollframe:Show()
				MapandNavcontentframe:Show()
				
				end)
				
-- -- -- -- -- MapandNavExploreButton -- -- -- -- --
local button = CreateFrame("Button", "MapandNavExploreButton", MapandNavStartMenu, "UIPanelButtonTemplate")
button:SetText("Explore")
button:SetPoint("RIGHT", -50,0)
button:SetWidth(180)
button:SetHeight(180)
button:RegisterForClicks("AnyUp")
button:SetScript("OnClick", 
				function (self, button, down)
				MapandNavExploreButton:Hide()

				MapandNavFindButton:Hide()

				end)
Find.lua
Code:
--parent frame 
local frame = CreateFrame("Frame", "MapandNavFindscrollparentframe", MapandNavStartMenu) 
frame:Hide()
frame:SetSize(400, 200) 
frame:SetPoint("CENTER", MapandNavStartMenu, "CENTER", 0,0) 
local texture = frame:CreateTexture() 
texture:SetAllPoints() 
texture:SetTexture(0,0,0,0) 
frame.background = texture 

--scrollframe 
scrollframe = CreateFrame("ScrollFrame", "MapandNavscrollframe", frame) 
scrollframe:SetPoint("TOPLEFT", 0,0) 
scrollframe:SetPoint("BOTTOMRIGHT", 0,0) 
local texture = scrollframe:CreateTexture() 
texture:SetAllPoints() 
texture:SetTexture(0,0,0,0) 
frame.scrollframe = scrollframe 

--scrollbar 
scrollbar = CreateFrame("Slider", nil, scrollframe, "UIPanelScrollBarTemplate") 
scrollbar:SetPoint("TOPLEFT", frame, "TOPRIGHT", 6, -22) 
scrollbar:SetPoint("BOTTOMLEFT", frame, "BOTTOMRIGHT", 0,2) 
scrollbar:SetMinMaxValues(1, 200) --How Far the Bar Goes Down and Moves the Frame
scrollbar:SetValueStep(1) 
scrollbar.scrollStep = 1 
scrollbar:SetValue(0) 
scrollbar:SetWidth(16)
 
scrollbar:SetScript("OnValueChanged", 
function (self, value) 
self:GetParent():SetVerticalScroll(value) 
end) 
local scrollbg = scrollbar:CreateTexture(nil, "BACKGROUND") 
scrollbg:SetAllPoints(scrollbar) 
scrollbg:SetTexture(0, 0, 0, 0.4) 
frame.scrollbar = scrollbar 

--content frame 
local content = CreateFrame("Frame", "MapandNavcontentframe", MapandNavscrollframe) 
content:SetSize(500, 300) 


--local texture = content:CreateTexture() 
--texture:SetAllPoints() 
--texture:SetTexture("Interface\\GLUES\\MainMenu\\Glues-BlizzardLogo") 
--content.texture = texture 

scrollframe.content = content 
 
scrollframe:SetScrollChild(content)

-- Table describing the buttons you want to create:
local buttonData = {
	{
		text = "Auction House",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT1")
			MapandNavFindtabelperantframe:Hide()
			MapandNavFindtabelperantframe:SetParent(nil)
			MapandNavCitySelecttabelperantframe:Show()
			
			
		end,
	},
	{
		text = "Bank",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT2")
		end,
	},
	{
		text = "Barber",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT3")
		end,
	},
	{
		text = "Battle Pet Trainer",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT4")
		end,
	},
	{
		text = "Class Trainer",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT5")
		end,
	},
		{
		text = "Flight Master",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT6")
		end,
	},
	{
		text = "Guild Master",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT7")
		end,
	},
	{
		text = "Guild Vendor",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT8")
		end,
	},
	{
		text = "Inn",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT9")
		end,
	},
	{
		text = "Mailbox",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT1")
		end,
	},
	{
		text = "Points of Interest",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT2")
		end,
	},
	{
		text = "Portals",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT3")
		end,
	},
	{
		text = "Profession Trainer",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT4")
		end,
	},
	{
		text = "Reforge",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT5")
		end,
	},
	{
		text = "Stable Master",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT6")
		end,
	},
	{
		text = "Transmogrification",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT7")
		end,
	},
	{
		text = "Vendor",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT8")
		end,
	},
	{
		text = "Void Storage",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT9")
		end,
	},
}

-- Table to hold the actual button objects:
local buttons = {}

-- Create the container frame:
local frame = CreateFrame("Frame", "MapandNavFindtabelperantframe", MapandNavcontentframe)
frame:Hide()
frame:SetPoint("TOPLEFT", MapandNavcontentframe, 0, 0)
frame:SetSize(200, 20)

-- Give it a background:
local backdrop = frame:CreateTexture(nil, "BACKDROP")
backdrop:SetAllPoints(true)
backdrop:SetTexture(0, 0, 0, 0)

-- Loop over the data list:
for i = 1, 9 do -- For all button data use for i = 1, #buttonData do
	-- For each entry, create a button:
	local button = CreateFrame("Button", "FindTableOptionsLEFT"..i, frame, "UIPanelButtonTemplate")
	button:SetWidth(200)
	button:SetHeight(40)

	-- Add the button to the table:
	buttons[i] = button

	-- Attach the data for later reference:
	button.data = buttonData[i]

	-- Set the button's text based on the data:
	button:SetText(button.data.text)
	-- Set the OnClick script based on the data:
	button:SetScript("OnClick", button.data.click)

	-- If this is the first button...
	if i == 1 then
		-- ...anchor the button to the container:
		button:SetPoint("TOP", frame, "BOTTOM", 0, 20)
	else
		-- ...otherwise, anchor it to the previous button:
		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -5)
	end
end

-- Loop over the data list:
for i = 10, 18 do -- For all button data use for i = 1, #buttonData do
	-- For each entry, create a button:
	local button = CreateFrame("Button", "FindTableOptionsRIGHT"..i, frame, "UIPanelButtonTemplate")
	button:SetWidth(200)
	button:SetHeight(40)

	-- Add the button to the table:
	buttons[i] = button

	-- Attach the data for later reference:
	button.data = buttonData[i]

	-- Set the button's text based on the data:
	button:SetText(button.data.text)
	-- Set the OnClick script based on the data:
	button:SetScript("OnClick", button.data.click)

	-- If this is the first button...
	if i == 10 then
		-- ...anchor the button to the container:
		button:SetPoint("TOPLEFT", frame, "BOTTOM", 100, 20)
	else
		-- ...otherwise, anchor it to the previous button:
		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -5)
	end
end


-- Now your "buttons" table looks like this:
-- buttons = {
-- 	[1] = <button object named "MyButton1">,
-- 	[2] = <button object named "MyButton2">,
-- }

-- Table describing the buttons you want to create:
local buttonData = {
	{
		text = "Dalaran",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT1")
			
		end,
	},
	{
		text = "Darnassus",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT2")
			
		end,
	},
	{
		text = "Exodar",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT3")
			
		end,
	},
	{
		text = "Ironforge",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT4")
			
		end,
	},
	{
		text = "Orgrimmar",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT5")
			
		end,
	},
	{
		text = "Shattrath City",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT6")
			
		end,
	},
	{
		text = "Shrine of Seven Stars",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT1")
			
		end,
	},
	{
		text = "Shrine of Two Moons",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT2")
			
		end,
	},
	{
		text = "Silvermoon City",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT3")
			
		end,
	},
	{
		text = "Stormwind City",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT4")
			
		end,
	},
	{
		text = "Thunder Bluff",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT5")
			
		end,
	},
	{
		text = "Undercity",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT6")
			
		end,
	},
}


-- Table to hold the actual button objects:
local buttons = {}

-- Create the container frame:
local frame = CreateFrame("Frame", "MapandNavCitySelecttabelperantframe", MapandNavcontentframe)
frame:Hide()
frame:SetPoint("TOPLEFT", MapandNavcontentframe, 0, 0)
frame:SetSize(200, 20)

-- Give it a background:
local backdrop = frame:CreateTexture(nil, "BACKDROP")
backdrop:SetAllPoints(true)
backdrop:SetTexture(0, 0, 0, 0)

-- Loop over the data list:
for i = 1, 6 do -- For all button data use for i = 1, #buttonData do
	-- For each entry, create a button:
	local button = CreateFrame("Button", "FindTableOptionsLEFT"..i, frame, "UIPanelButtonTemplate")
	button:SetWidth(200)
	button:SetHeight(40)

	-- Add the button to the table:
	buttons[i] = button

	-- Attach the data for later reference:
	button.data = buttonData[i]

	-- Set the button's text based on the data:
	button:SetText(button.data.text)
	-- Set the OnClick script based on the data:
	button:SetScript("OnClick", button.data.click)

	-- If this is the first button...
	if i == 1 then
		-- ...anchor the button to the container:
		button:SetPoint("TOP", frame, "BOTTOM", 0, 20)
	else
		-- ...otherwise, anchor it to the previous button:
		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -5)
	end
end

-- Loop over the data list:
for i = 7, 12 do -- For all button data use for i = 1, #buttonData do
	-- For each entry, create a button:
	local button = CreateFrame("Button", "FindTableOptionsRIGHT"..i, frame, "UIPanelButtonTemplate")
	button:SetWidth(200)
	button:SetHeight(40)

	-- Add the button to the table:
	buttons[i] = button

	-- Attach the data for later reference:
	button.data = buttonData[i]

	-- Set the button's text based on the data:
	button:SetText(button.data.text)
	-- Set the OnClick script based on the data:
	button:SetScript("OnClick", button.data.click)

	-- If this is the first button...
	if i == 10 then
		-- ...anchor the button to the container:
		button:SetPoint("TOPLEFT", frame, "BOTTOM", 100, 20)
	else
		-- ...otherwise, anchor it to the previous button:
		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -5)
	end
end


-- Now your "buttons" table looks like this:
-- buttons = {
-- 	[1] = <button object named "MyButton1">,
-- 	[2] = <button object named "MyButton2">,
-- }
CitySelect.lua
Code:
-- Table describing the buttons you want to create:
local buttonData = {
	{
		text = "Dalaran",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT1")
			
		end,
	},
	{
		text = "Darnassus",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT2")
			
		end,
	},
	{
		text = "Exodar",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT3")
			
		end,
	},
	{
		text = "Ironforge",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT4")
			
		end,
	},
	{
		text = "Orgrimmar",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT5")
			
		end,
	},
	{
		text = "Shattrath City",
		click = function(self, mouseButton)
			print("FindTableOptionsLEFT6")
			
		end,
	},
	{
		text = "Shrine of Seven Stars",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT1")
			
		end,
	},
	{
		text = "Shrine of Two Moons",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT2")
			
		end,
	},
	{
		text = "Silvermoon City",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT3")
			
		end,
	},
	{
		text = "Stormwind City",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT4")
			
		end,
	},
	{
		text = "Thunder Bluff",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT5")
			
		end,
	},
	{
		text = "Undercity",
		click = function(self, mouseButton)
			print("FindTableOptionsRIGHT6")
			
		end,
	},
}


-- Table to hold the actual button objects:
local buttons = {}

-- Create the container frame:
local frame = CreateFrame("Frame", "MapandNavCitySelecttabelperantframe", MapandNavcontentframe)
frame:Hide()
frame:SetPoint("TOPLEFT", MapandNavcontentframe, 0, 0)
frame:SetSize(200, 20)

-- Give it a background:
local backdrop = frame:CreateTexture(nil, "BACKDROP")
backdrop:SetAllPoints(true)
backdrop:SetTexture(0, 0, 0, 0)

-- Loop over the data list:
for i = 1, 6 do -- For all button data use for i = 1, #buttonData do
	-- For each entry, create a button:
	local button = CreateFrame("Button", "FindTableOptionsLEFT"..i, frame, "UIPanelButtonTemplate")
	button:SetWidth(200)
	button:SetHeight(40)

	-- Add the button to the table:
	buttons[i] = button

	-- Attach the data for later reference:
	button.data = buttonData[i]

	-- Set the button's text based on the data:
	button:SetText(button.data.text)
	-- Set the OnClick script based on the data:
	button:SetScript("OnClick", button.data.click)

	-- If this is the first button...
	if i == 1 then
		-- ...anchor the button to the container:
		button:SetPoint("TOP", frame, "BOTTOM", 0, 20)
	else
		-- ...otherwise, anchor it to the previous button:
		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -5)
	end
end

-- Loop over the data list:
for i = 7, 12 do -- For all button data use for i = 1, #buttonData do
	-- For each entry, create a button:
	local button = CreateFrame("Button", "FindTableOptionsRIGHT"..i, frame, "UIPanelButtonTemplate")
	button:SetWidth(200)
	button:SetHeight(40)

	-- Add the button to the table:
	buttons[i] = button

	-- Attach the data for later reference:
	button.data = buttonData[i]

	-- Set the button's text based on the data:
	button:SetText(button.data.text)
	-- Set the OnClick script based on the data:
	button:SetScript("OnClick", button.data.click)

	-- If this is the first button...
	if i == 10 then
		-- ...anchor the button to the container:
		button:SetPoint("TOPLEFT", frame, "BOTTOM", 100, 20)
	else
		-- ...otherwise, anchor it to the previous button:
		button:SetPoint("TOP", buttons[i-1], "BOTTOM", 0, -5)
	end
end


-- Now your "buttons" table looks like this:
-- buttons = {
-- 	[1] = <button object named "MyButton1">,
-- 	[2] = <button object named "MyButton2">,
-- }

Last edited by Yksrep : 07-16-13 at 03:43 AM.
  Reply With Quote