Garry's Mod Wiki

Panel:LocalCursorPos

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:

Page Links


Special Pages


Wikis

?

Render Time: 33ms

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