Garry's Mod Wiki

gui

The gui library is similar to the input but features functions that are more focused on the mouse's interaction with GUI panels.

Methods

Opens the game menu overlay.
gui.AddCaption( string text, number duration, boolean fromPlayer = false )
Pushes text to the closed caption box. The function will not work, if the console command variable "closecaption" is set to 0.
Enables the mouse cursor without restricting player movement, like using Sandbox's context menu. See vgui. CursorVisible for a function to see if the cursor is visible or not. Some CUserCmd functions will return incorrect values when this function is active because the user input is getting overtaken by the vgui system.
gui.HideGameUI()
Hides the game menu overlay. We advise against using this. It may be changed or removed in a future update. Will be disabled in a future patch. Use GM:OnPauseMenuShow instead.
gui.InternalCursorMoved( number deltaX, number deltaY )
Simulates a mouse move with the given deltas.
Simulates a key press for the given key.
Simulates a key release for the given key.
Simulates a key type typing to the specified key.
Simulates an ASCII symbol writing. Use to write text in the chat or in VGUI. Doesn't work while the main menu is open!
Simulates a double mouse key press for the given mouse key.
Simulates a mouse key press for the given mouse key.
Simulates a mouse key release for the given mouse key.
Simulates a mouse wheel scroll with the given delta.
Returns whether the console is visible or not.
Returns whether the game menu overlay ( main menu ) is open or not.
We advise against using this. It may be changed or removed in a future update. Use input. GetCursorPos instead. Returns the cursor's position on the screen, or 0, 0 if cursor is not visible.
Returns x component of the mouse position.
Returns y component of the mouse position.
gui.OpenURL( string url )
Opens specified URL in the steam overlay browser. When called clientside, user will be asked for confirmation before the website will open.
Converts the specified screen position to a direction vector local to the player's view. A related function is Vector:ToScreen, which translates a 3D position to a screen coordinate. util. AimVector is a more generic version of this, using a custom view instead of the player's current view.
gui.SetMousePos( number mouseX, number mouseY )
We advise against using this. It may be changed or removed in a future update. Use input. SetCursorPos instead. Sets the cursor's position on the screen, relative to the topleft corner of the window
Shows console in the game UI.