-
Posted by docseuss on Mon, 30 Nov 2009 17:27:48
I already have a thread going on this subject over on WowAce, but I thought I would also post it here to get additional input.
Hello all, I am in the process of writing my first addon and things in my opinion are going fairly well. I decided to use the Ace library as I have always loved Ace Addons and after doing my research it seemed to fit the bill.
However with that being said I do have a question about AceGUI-3.0 and the SimpleHTML widget. I believe I have the widget defined correctly and it added to AceGUI correctly, but I cannot for the life of me figure out how to assign the html file to it. So this may be a SimpleHTML widget question as opposed to a AceGUI question, but either way any help would greatly be appreciated.
Basically I have a folder that contains the various help files in html format. What I want to do is simply open a window using AceGUI, which works, and load in the appropriate html file. Below is the code I have so far. The SetText method of the SimpleHTML widget seems to work, but I saw examples online where you can do a file="Help\HelpFile.html" in the XML portion of a SimpleHTML and it pulls the file content. I want to do the same, but from the lua side of things.
Again any help or direction that you could offer would be appreciated.
Widget Code
----------------------------------------------------- -- HELP WIDGET ----------------------------------------------------- do local Type = "SimpleHTML" local Version = 8 local function OnAcquire(self) self:SetText("") end local function OnRelease(self) self.frame:ClearAllPoints() self.frame:Hide() end local function SetText(self, text) self.frame:SetText(text or "") end local function SetWidth(self, w) self.frame:SetWidth(w) end local function Constructor() local frame = CreateFrame("SimpleHTML",nil,UIParent) local self = {} self.type = Type self.OnRelease = OnRelease self.OnAcquire = OnAcquire self.SetText = SetText self.SetWidth = SetWidth self.frame = frame frame.obj = self frame:SetHeight(18) frame:SetWidth(200) frame:SetFontObject(GameFontHighlightSmall) AceGUI:RegisterAsWidget(self) return self end AceGUI:RegisterWidgetType(Type,Constructor,Version) end
Create the help frame and assign the appropriate html file
-- Create a container frame local f = AceGUI:Create("Frame") f:SetCallback("OnClose",function(widget) AceGUI:Release(widget) end) f:SetTitle("Personal Loot Help") --f:SetStatusText("Status Bar") f:SetLayout("Flow") local html = AceGUI:Create("SimpleHTML") html:SetWidth(170) html.file = "Help\PersonalLoot.html" -- Add the SimpleHTML to the container f:AddChild(html)
-
Posted by jnwhiteh on Mon, 30 Nov 2009 19:03:57
If anything you'd have to provide the full path:
Interface\AddOns\Blah\Help\Foo.html
But I've never seen that style used anywhere.
-
Posted by docseuss on Tue, 01 Dec 2009 05:21:57
Yeah I have not been able to find any online examples as well, but I did happen by Barnes and Noble tonight and picked up Beginning Lua with World of Warcraft Add-ons. I figured it would be a good compliment to your book as it covers a lot of the same topics, but offers some different examples.
This book also references the file xml attribute of the SimpleHTML widget and says it is used to display html files with in the widget, but then when it covers the lua portion of the widget it does not mention the file attribute nor does it show a method to set the file in lua. I guess this really is a XML only attribute which is strange to me.
The only online example I found was in this thread on WorldofWar.net forums, http://forums.worldofwar.net/showthread.php?t=372060. They show this example and the OP does reply that he had to use the full path, but it did indeed work.
<SimpleHTML name="MyHTML" file="MyHtmlFile.html"> .. Anchors .. Size .. Layers .. Frames <FontString inherits="GameFontNormal"/> <FontStringHeader1 inherits="GameFontNormalLarge"/> </SimpleHTML>
If anyone comes up with any good ideas to dynamically load a html file into the SimpleHTML widget I'd love to hear them.
Thanks everyone!
-
Posted by jnwhiteh on Tue, 01 Dec 2009 09:26:53
The best we could do is ask for a method to load it at runtime.. it's probably an oversight that it hasn't been included previously.
-
Posted by docseuss on Tue, 01 Dec 2009 15:56:10
James, Thank you for your replys and also the great book you put out. I am having a lot of fun transtioning my skill set to the lua/WoW world.
If they could add that even at runtime that would be cool. Would another possibilty be to define the SimpleHTML frame as an xml template file and then create a SimpleHTML frame in lua and inherit the XML version that had the file attribute set?
Again appreciate all your involvement in the addon community!
-
Posted by GeodesicDragon on Wed, 09 Dec 2009 22:18:33
Sorry to piggyback on the thread, but I am also having problems getting this to work.
I can't find any step by step guides anywhere and I am quickly losing patience trying to get my addon to display a SimpleHTML frame. I've got an HTML file already, and I have
<SimpleHTML name="MyHTML" file="Interface\\Addons\\VGComms\\help\\commands.html"> <FontString inherits="GameFontNormal"/> <FontStringHeader1 inherits="GameFontNormalLarge"/> </SimpleHTML>
in my XML file. But I can't get it to show up. I've tried using MySimpleHTMLFrame:include("Interface\Addons\VGComms\help\commands.html") but all I get is a Lua error.
I have read tutorial after tutorial and followed their instructions, all to no avail. My last hope lies here, as I have had such great help in the past.
Thanks!
-
Posted by jnwhiteh on Wed, 09 Dec 2009 23:04:22
I suggest you don't use the file argument, and simply set the HTML directly using SimpleHTML:SetText().
Are you anchoring the frame somewhere? Giving it a size?
-
Posted by GeodesicDragon on Thu, 10 Dec 2009 12:06:19
OK, I got it to work.
Now, I see that it doesn't scroll automatically. How do I add a scrollbar to it?
... Blizzard seem to enjoy making things hard for Lua coders.
-
Posted by jnwhiteh on Thu, 10 Dec 2009 12:11:07
There's a whole chapter on scroll frames, I suggest you take a look at that. Blizzard isn't making anything "hard" for us. It doesn't make sense for a SimpleHTML frame (nor any other type of frame) to have a native scrollbar. The widgets are general on purpose so you can build whatever you need out of them.
Essentially you need to set the SimpleHTML frame as the scrollchild of a scrollframe and then create sliders for the scrolling bit.