Thread Tools Display Modes
04-01-18, 02:34 PM   #1
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Question itemLinks in an addon frame?

Hi. I've been trying to find out if it's possible to have clickable itemLinks on a frame I've created myself? I feel like I can't find any information on this and tweaking things myself has gotten me nowhere. Is this only available in the default chat frames?

For example:

Code:
local frame = CreateFrame("Frame", "testFrame", UIParent, "BasicFrameTemplate")
frame:SetPoint("CENTER", 0, 0)
frame:SetSize(500, 500)
frame:EnableMouse(true)
frame:SetHyperlinksEnabled(true)

local item, itemLink = GetItemInfo(21841)

local line = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight")
line:SetPoint("CENTER", 0, 0)
line:SetText(itemLink)
This creates the frame and adds the the itemLink, but it's not clickable. Is there another setting I'm missing? Or is this just not possible. Or would it require some annoying workaround where I create a button that I format next to the font string (which I hope not because in my actual implementation, I'm already using a format function for my string).
  Reply With Quote
04-01-18, 05:40 PM   #2
Vrul
A Scalebane Royal Guard
 
Vrul's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2007
Posts: 404
You have to tell your frame what to do when a hyperlink is interacted with by setting the relevant scripts for OnHyperlinkClick, OnHyperlinkEnter, and/or OnHyperlinkLeave. If you want hyperlinks to act like the default chat frames then all you need to do is add:
Code:
frame:SetScript("OnHyperlinkClick", ChatFrame_OnHyperlinkShow)
  Reply With Quote
04-02-18, 01:39 AM   #3
Niketa
A Wyrmkin Dreamwalker
 
Niketa's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2013
Posts: 54
Thank you! Shame I spent so much time banging my head on such a simple issue. lol
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » itemLinks in an addon frame?

Thread Tools
Display Modes

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