Garry's Mod Wiki

Garry's Mod Wiki

  table DTextEntry:GetAutoComplete( string inputText )

Description

Called by the DTextEntry when a list of autocompletion options is requested. Meant to be overridden.

Arguments

1 string inputText
Player's current input.

Returns

1 table
If a table is returned, the values of the table will show up as autocomplete suggestions for the user.

Example

Shows a list of players to choose from.

local frame = vgui.Create( "DFrame" ) frame:SetSize( 300, 300 ) frame:SetTitle( "Autocompletion Example" ) frame:Center() frame:MakePopup() local label = vgui.Create( "DLabel", frame ) label:SetText( "Type a player..." ) label:Dock( TOP ) local textentry = vgui.Create( "DTextEntry", frame ) textentry:Dock( TOP ) function textentry:GetAutoComplete( text ) local suggestions = {} for _, ply in ipairs( player.GetAll() ) do -- For every player, if string.StartWith( ply:Nick(), text ) then -- if the player's name starts with it... table.insert( suggestions, ply:Nick() ) -- ... insert it into the list. end end return suggestions end
Output:

This site is a community mirror of the official Garry's Mod wiki.. This site is not maintained by Facepunch Studios.

Page content is automatically updated twice a day. Edits and history are not available.

Last Parsed: Loading...