Problem with "richtext".

Two things i can’t do with richtext which kind of makes me disappointed:

  • Cannot set the font with panel:SetFont()
  • Cannot use panel:Clear(true)

Are there any alternatives on how to set the font? Does it actually have HTML support(if so how can i set the font with HTML and does it keep the scrollbar?). What my basic goal is to make a panel from which you can copy text and which also scrolls. I have that with richtext but the font is just too small.

SetFont SHOULD work as far as I am concerned since I used it earlier, for clearing simply drop the current control and create a new one, not exactly the best way but one way.

[editline]25th January 2013[/editline]

Well weird, it was documented on the old wiki for some reason, but SetFont is not bound, while garry certainly could do that easily, clearing is easily possible via SetText apparently.

I know it should work but it doesn’t i tried it. Neither of your points. SetText doesn’t seem to clear the text either, it kinda keeps the previously appended text in memory and overlaps. Here’s an example of my darkrp Rules tab:



function GM:Rules()
	local Rulestab = vgui.Create("DPanelList")
		function Rulestab:Update()
			self:Clear(true)
				local rules = vgui.Create("RichText", Rulestab)		
				rules:SetVerticalScrollbarEnabled (true)
                                rules:SetFont ( "anyfontreally" ) -- Says SetFont returns nil
                                rules:SetText ("") -- Should clear the text right? Well it doesn't or i am doing something really wrong
				rules:AppendText("Loads of rules... blah blah ")		
				rules:StretchToParent(20,70,20,30)
				rules:SizeToContents()	
				local title = vgui.Create("DLabel", Rulestab)
				title:AlignLeft(ScrW()/4)
				title:SetText("RULES!")
				title:SetFont("HUDNumber5")	
				title:SizeToContents()	
				
	    end
		Rulestab:Update()
		return Rulestab
end


Edit:
In my current script i don’t use any clearing at all, i just let the rules be appended once and then just keep them, otherwise stuff just starts randomly overlapping, havent tried using :Remove() yet though.

Well, the richtext control is rather unsupported anyway…

Yeah i just moved onto HTML, i must say though that for a richtext, it ain’t that rich. Thanks for the help anyway :slight_smile: