Garry's Mod Wiki

Garry's Mod Wiki

  number, number Panel:LocalCursorPos()

Description

Returns the cursor position local to the position of the panel (usually the upper-left corner).

Returns

1 number
The x coordinate
2 number
The y coordinate

Example

Create and center a label panel and update its text with the local cursor position.

TestLabel = vgui.Create("DLabel") TestLabel:SetSize(100, 20) TestLabel:Center() TestLabel:SetPaintBackgroundEnabled(true) TestLabel:SetColor(Color(255, 0, 0)) local x, y = 0, 0 function TestLabel:PerformLayout() x, y = self:LocalCursorPos() self:SetText(" X: "..x.." , Y: "..y) 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 four times a day. Edits and history are not available.

Last Parsed: Loading...