Quantcast
WoWInterface - View Single Post - How to build UI in order to present a table?
View Single Post
04-02-21, 09:15 AM   #4
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 151
The html used by the SimpleHtml has many limits. If you get the whole html, it means the widget reject to render it.

You should check the Well-formed HTML in the https://wowwiki-archive.fandom.com/w...ECT_SimpleHTML. Also concat string directly is a real pain.

Create custom UI is a big topic to be discussed here. You may discuss it in the [email protected]

And for the code to create such a frame, if you don't mind using other libs:

Click image for larger version

Name:	simplehtmltest.jpg
Views:	80
Size:	121.5 KB
ID:	9606

Lua Code:
  1. Scorpio "SimpleHtmlTest" ""  -- A Module based on my Scorpio Lib
  2.  
  3. -- Create a dialog to contains the viewer
  4. Browser                         = Dialog("SimpleHtmlTestBrowser")
  5.  
  6. -- Create the html view from a template class based on the SimpleHtml
  7. viewer                          = HtmlViewer  ("Viewer", Browser)
  8.  
  9. -- Handle the link click
  10. function viewer:OnHyperlinkClick(path)
  11.     if path then
  12.         -- Click the link and send to the chat box for copy
  13.         ChatEdit_ActivateChat(ChatFrame1EditBox)
  14.         ChatFrame1EditBox:SetText(path)
  15.         ChatFrame1EditBox:HighlightText(0, #path)
  16.     end
  17. end
  18.  
  19. -- The style of those ui, just like xml with properties.
  20. Style[Browser]                  = {
  21.     Header                      = { Text = "Table Viewer" },
  22.     Size                        = Size(800, 600),
  23.     clampedToScreen             = true,
  24.     minResize                   = Size(600, 400),
  25.  
  26.     Viewer                      = {
  27.         location                = { Anchor("TOPLEFT", 24, -32), Anchor("BOTTOMRIGHT", -48, 48) },
  28.     },
  29. }
  30.  
  31.  
  32. -- A template string used to generate the target string with data
  33. -- @xxx is the directives for lua codes, so here `name` and `target`
  34. -- are the special variables to generate the final string
  35. TEMPLATE_TABLE                  = System.Text.TemplateString[[
  36.     <html>
  37.         <body>
  38.             <h1>@name</h1>
  39.             <br/>
  40.             @for k, v in pairs(target) do
  41.             <p><a href="@k">@k</a></p>
  42.             @end
  43.         </body>
  44.     </html>
  45. ]]
  46.  
  47. -- A test
  48. viewer:SetText(TEMPLATE_TABLE{
  49.     name = "C_AuctionHouse",
  50.     target = C_AuctionHouse,
  51. })

It'd could be more longer to create this without a lib.

So this is an ADs

The Scorpio is a power addon dev platform, you can find my post at https://www.wowinterface.com/forums/...splay.php?f=41.

I don't really like blz's mixin system, but you still can find me in the discord.
  Reply With Quote