Garry's Mod Wiki


  DTextEntry:AddHistory( string text )


Adds an entry to DTextEntry's history.

See DTextEntry:SetHistoryEnabled.


1 string text
Text to add to the text entry's history.


A simple example.

-- Create a new frame (window) local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 300 ) -- Set the size of the frame frame:Center() -- Center the frame on the screen frame:MakePopup() -- Make the frame appear in front of other windows and accept user input -- Create a text entry field within the frame local tEntry = vgui.Create("DTextEntry", frame) tEntry:Dock(TOP) -- Dock the text entry at the top of the frame tEntry:SetHistoryEnabled(true) -- Dock the text entry at the top of the frame tEntry.OnEnter = function( self ) local val = self:GetValue() self:AddHistory( val ) -- Store old value in history so the player can access it again later self:SetText( "" ) -- reset the text -- Do something with the data... chat.AddText( val ) -- print the textentry text as a chat message end