Garry's Mod Wiki

Panel:CursorPos

  number, number Panel:CursorPos()

Description

Returns the cursor position relative to the top left of the panel.

This is equivalent to calling gui.MousePos and then Panel:ScreenToLocal.

This function uses a cached value for the screen position of the panel, computed at the end of the last VGUI Think/Layout pass.

ie. inaccurate results may be returned if the panel or any of its ancestors have been repositioned outside of PANEL:Think or PANEL:PerformLayout within the last frame.

Returns

1 number
X coordinate of the cursor, relative to the top left of the panel.
2 number
Y coordinate of the cursor, relative to the top left of the panel.