Garry's Mod Wiki

Panel:GotoTextStart

Panel:GotoTextStart()

Description

Causes a RichText element to scroll to the top of its text.

This does not work on the same frame as Panel:SetText.

Issue Tracker: 2239

Example

Creates a RichText panel with a "Back to Top" button which scrolls the text to the start.

-- Create a window frame TextFrame = vgui.Create("DFrame") TextFrame:SetSize(250, 200) TextFrame:Center() TextFrame:SetTitle("#ServerBrowser_ServerWarningTitle") TextFrame:MakePopup() -- RichText panel local richtext = vgui.Create("RichText", TextFrame) richtext:Dock(FILL) -- Yellow colored localized text about player capacity richtext:InsertColorChange(255, 255, 192, 255) richtext:AppendText("#ServerBrowser_ServerWarning_MaxPlayers") -- Create a button that moves the text back to the start local topbutton = vgui.Create("DButton", richtext) topbutton:SetSize(60, 20) topbutton:SetPos(160, 146) topbutton:SetText("Back to Top") -- When clicked, go to the start of the text topbutton.DoClick = function() richtext:GotoTextStart() end -- Apply background color and font function richtext:PerformLayout() self:SetFontInternal("Trebuchet18") self:SetBGColor(Color(64, 64, 84)) end
Output:

Page Links


Special Pages


Wikis

?

Render Time: 31ms

DB GetPage 4
Generate Html 4
SaveChanges (1) 8
Render Body 0
Render Sidebar 12