Thread Tools Display Modes
02-18-24, 05:11 AM   #1
Hubb777
A Flamescale Wyrmkin
 
Hubb777's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2024
Posts: 111
clickable link to the item in the table

Hello everyone. There are two lua files
The first one displays the table

Lua Code:
  1. local addonName, addon = ...
  2.  
  3. local CELL_WIDTH = 400
  4. local CELL_HEIGHT = 80
  5. local NUM_CELLS = 2
  6.  
  7. local data = {}
  8.  
  9. local f = CreateFrame("Frame", "SimpleScrollFrameTableDemo", UIParent, "BasicFrameTemplateWithInset")
  10.  
  11. -- Create the button here
  12. local btn = CreateFrame("Button", nil, UIParent, "UIPanelButtonTemplate")
  13.  
  14. local function updateData() --commented out because addon.db hasn't been created... in the code at least
  15.     wipe(data)
  16.     for _, item in ipairs(addon.db) do
  17.         tinsert(data, {item.announce[GetLocale()], item.icon, item.name})
  18.     end
  19. end
  20.  
  21. f:SetSize(CELL_WIDTH * NUM_CELLS + 80, 600)
  22. f:SetPoint("CENTER")
  23. f:Hide()
  24. f:SetMovable(true)
  25. f:SetScript("OnMouseDown", f.StartMoving)
  26. f:SetScript("OnMouseUp", f.StopMovingOrSizing)
  27.  
  28. -- I added this OnHide script
  29. f:SetScript("OnHide", function()
  30.     btn:Show()
  31. end)
  32.  
  33. f.scrollFrame = CreateFrame("ScrollFrame", nil, f, "UIPanelScrollFrameTemplate")
  34. f.scrollFrame:SetPoint("TOPLEFT", 12, -32)
  35. f.scrollFrame:SetPoint("BOTTOMRIGHT", -34, 8)
  36.  
  37. f.scrollFrame.scrollChild = CreateFrame("Frame", nil, f.scrollFrame)
  38. f.scrollFrame.scrollChild:SetSize(100, 100)
  39. f.scrollFrame.scrollChild:SetPoint("TOPLEFT", 5, -5)
  40. f.scrollFrame:SetScrollChild(f.scrollFrame.scrollChild)
  41.  
  42. local content = f.scrollFrame.scrollChild
  43. content.rows = {}
  44.  
  45. local function updateList()
  46.     for i = 1, #data do
  47.         if not content.rows[i] then
  48.             local button = CreateFrame("Button", nil, content)
  49.             button:SetSize(CELL_WIDTH * NUM_CELLS, CELL_HEIGHT)
  50.             button:SetPoint("TOPLEFT", 0, -(i - 1) * CELL_HEIGHT)
  51.             button.columns = {}
  52.  
  53.             button.columns[1] = button:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
  54.             button.columns[1]:SetPoint("LEFT", (0) * CELL_WIDTH, 0)
  55.  
  56.             button.columns[2] = button:CreateTexture()
  57.             button.columns[2]:SetPoint("LEFT", 410, 0, (1) * CELL_WIDTH, 0)
  58.  
  59.             button.columns[3] = button:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
  60.             button.columns[3]:SetPoint("LEFT", 480, 0, (2) * CELL_WIDTH, 0)
  61.  
  62.             content.rows[i] = button
  63.         end
  64.  
  65.         content.rows[i].columns[1]:SetText(data[i][1])
  66.         content.rows[i].columns[2]:SetTexture(data[i][2])
  67.         content.rows[i].columns[3]:SetText(data[i][3])
  68.  
  69.         content.rows[i]:Show()
  70.     end
  71.  
  72.     for i = #data + 1, #content.rows do
  73.         content.rows[i]:Hide()
  74.     end
  75. end
  76.  
  77.  
  78. -- Set your button options here
  79. local btn = CreateFrame("Button", "Hubb777MovingButton", UIParent, "UIPanelButtonTemplate")
  80. btn:SetPoint("CENTER")
  81. btn:SetSize(100, 40)
  82. btn:SetText("Click me")
  83. btn:SetMovable(true)
  84. btn:RegisterForDrag('LeftButton')
  85. btn:RegisterForClicks("AnyDown", "AnyUp")
  86. btn:SetUserPlaced(true)
  87. btn:SetScript('OnDragStart', function(self, button, down)
  88.     if button == "LeftButton" and IsShiftKeyDown() then
  89.         self:StartMoving()
  90.     end
  91. end)
  92. btn:SetScript('OnDragStop', function(self)
  93.     self:StopMovingOrSizing()
  94. end)
  95. btn:SetScript("OnMouseUp", function(self, button, ...)
  96.     if (button == "RightButton" and self:IsVisible()) then
  97.         self:Hide()
  98.     elseif button == "LeftButton" and not IsShiftKeyDown() then
  99.         updateData()
  100.         updateList()
  101.         f:Show()
  102.     end
  103. end)
  104.  
  105. SLASH_HUBB1 = "/hubb"
  106. SlashCmdList["HUBB"] = function(msg)
  107.     updateData()
  108.     updateList()
  109.     f:Show()
  110. end

The second file is a data table
Lua Code:
  1. local addonName, addon = ...
  2. addon.db = {
  3.     {
  4.         name = "Emerald Mark of Mastery",
  5.         questID = 75612,
  6.         icon = "interface/icons/inv_mushroom_11",
  7.         announce = {
  8.             enUS = "Awarded for outstanding service to Dragonkind.\n(clickable link to the item) \nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
  9.         }
  10.     },
  11.     {
  12.         name = "Emerald Mark of Mastery",
  13.         questID = 75624,
  14.         icon = "interface/icons/inv_mushroom_11",
  15.         announce = {
  16.             enUS = "Awarded for outstanding service to Dragonkind.\n(clickable link to the item) \nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
  17.         }
  18.     },
  19.     {
  20.         name = "Emerald Mark of Mastery",
  21.         questID = 74352,
  22.         icon = "interface/icons/inv_mushroom_11",
  23.         announce = {
  24.             enUS = "Awarded for outstanding service to Dragonkind.\n(clickable link to the item) \nBring it to Theozhaklos the Curious at the Wellspring \nOverlook in the Emerald Dream to receive powerful \nequipment for your efforts"
  25.         }
  26.     }
  27. }
How to add a clickable link to the item to the line along with "TEXT2"
Using the example of this item
Code:
/run local item = Item:CreateFromItemID(210399); local itemLink = item:GetItemLink(); local enUS = format("test %s test", itemLink); print(enUS);


It should look like - TEXT: Unlocks this customization option for the Renewed Proto-Drake at the Rostrum of Transformation link to the item TEXT: Renewed Proto-Drake: Love Armor.

Last edited by Hubb777 : 02-22-24 at 03:11 AM.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » clickable link to the item in the table


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