Thread Tools Display Modes
01-21-11, 09:53 PM   #1
thatdudegrim
A Deviate Faerie Dragon
Join Date: Sep 2010
Posts: 10
(SimpleHTML) Links are clickable, but not after updating

(This is my full lua code for this lua, it just deletes the repetitious bits such as additional uses of CreateBoxes() in WNCFrame_Load())

I'm having a strange problem and hope someone can help..

If I populate a the created field in CreateBoxes.. if I populate it inside create boxes, like the commented out #16, it works and populates fine and is clickable properly.

However if I populate it after, for instance in the EventFrame event-- effectively On-UPDATE_MOUSEOVER_UNIT--the box updates and the link shows properly but is not clickable.

lua Code:
  1. local thisType = ""
  2. local _G = getfenv()
  3.  
  4. function WNCFrame_Load()
  5.   CreateBoxes("DK")
  6. end
  7.  
  8. function CreateBoxes(wnc_boxname)
  9.     _G["info"..wnc_boxname]=CreateFrame("SimpleHTML","testaddon_Frame",WNCFrame); --creates the frame
  10.     _G["info"..wnc_boxname]:SetWidth(174); _G["info"..wnc_boxname]:SetHeight(40); --sets frame dimensions
  11.     _G["info"..wnc_boxname]:SetFontObject("SystemFont_Tiny"); --tells the frame to copy the styling from fontobject "GameFontNormal"
  12.     _G["info"..wnc_boxname]:SetJustifyH("LEFT"); --tells the frame to left-justify text
  13.     _G["info"..wnc_boxname]:SetJustifyV("TOP");
  14.     _G["info"..wnc_boxname]:SetScript("OnHyperlinkClick", function(self, ...) ChatFrame_OnHyperlinkShow(...) end); --tells the frame to use the default hyperlink "OnClick" action
  15.     _G["info"..wnc_boxname]:SetPoint("TOPLEFT",_G["label"..wnc_boxname],"BOTTOMLEFT"); --anchors the frame to the left edge of the screen
  16.      _G["info"..wnc_boxname]:SetText("\124cff71d5ff\124Hspell:45524\124h[Chains of Ice]\124h\124r");
  17. end
  18.  
  19. local EventFrame = CreateFrame("Frame")
  20. EventFrame:RegisterEvent("UPDATE_MOUSEOVER_UNIT")
  21. EventFrame:SetScript("OnEvent", function(self,event,...)
  22.     thisType = UnitCreatureType("mouseover")
  23.     ChatFrame1:AddMessage(_G["data"..thisType..".DK"]);
  24.     _G["infoDK"]:SetText("\124cff71d5ff\124Hspell:339\124h[Entangling Roots]\124h\124r");
  25. end)
  Reply With Quote
01-21-11, 10:34 PM   #2
thatdudegrim
A Deviate Faerie Dragon
Join Date: Sep 2010
Posts: 10
I found what I can only conclude is an amazingly inefficient way to make it work lol. (Lines 2,3,4,5)

lua Code:
  1. function CreateBoxes(wnc_boxname,wnc_boxvalue)
  2.     if _G["info"..wnc_boxname] then
  3.         _G["info"..wnc_boxname]:Hide()
  4.         _G["info"..wnc_boxname]:SetAttribute("Name","DestroyedWNC")
  5.     end
  6.     _G["info"..wnc_boxname]=CreateFrame("SimpleHTML","info"..wnc_boxname,WNCFrame); --creates the frame
  7.     _G["info"..wnc_boxname]:SetWidth(174); _G["info"..wnc_boxname]:SetHeight(40); --sets frame dimensions
  8.     _G["info"..wnc_boxname]:SetFontObject("SystemFont_Tiny"); --tells the frame to copy the styling from fontobject "GameFontNormal"
  9.     _G["info"..wnc_boxname]:SetJustifyH("LEFT"); --tells the frame to left-justify text
  10.     _G["info"..wnc_boxname]:SetJustifyV("TOP");
  11.     _G["info"..wnc_boxname]:SetScript("OnHyperlinkClick", function(self, ...) ChatFrame_OnHyperlinkShow(...) end); --tells the frame to use the default hyperlink "OnClick" action
  12.     _G["info"..wnc_boxname]:SetPoint("TOPLEFT",_G["label"..wnc_boxname],"BOTTOMLEFT"); --anchors the frame to the left edge of the screen
  13.     _G["info"..wnc_boxname]:SetText(wnc_boxvalue);
  14. end

and then I update the box like so.

lua Code:
  1. CreateBoxes("DK",_G["data"..thisType..".DK"])

Is there a way to Destroy a frame? I believe I've read there is not, but worth a shot to ask.

Rather frustrating (in this case at least) that two frames can have the same name lol.
  Reply With Quote
01-22-11, 02:11 AM   #3
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
nope no destroying frames we recycle them.
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
01-22-11, 05:02 AM   #4
thatdudegrim
A Deviate Faerie Dragon
Join Date: Sep 2010
Posts: 10
Thanks for the reply!

I'd love to recycle them for sure, but for some reason when I update the contents of a frame, it no longer responds to OnHyperlinkClick--I've even tried redeclaring everything as it was initially declared.

Anyone else ever experienced this?

Is there any sort of Frame:Refresh that will make it respond to new content?
  Reply With Quote
01-24-11, 05:24 AM   #5
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
How does Blizzard handle this? There's such a frame within the guild stuff, isn't it?
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » (SimpleHTML) Links are clickable, but not after updating


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