Garry's Mod Wiki

Revision Difference

Panel:SetCursor#526620

<function name="SetCursor" parent="Panel" type="classfunc"> <description>Sets the appearance of the cursor.</description> <realm>Client</realm> <args> <arg name="cursor" type="string">The cursor to be set. Can be one of the following: * arrow * beam * hourglass * waitarrow * crosshair * up * sizenwse * sizenesw * sizewe * sizens * sizeall * no * hand * blank Set to anything else to set it to "none", the default fallback. Do note that a value of "none" does not, as one might assume, result in no cursor being drawn - hiding the cursor requires a value of "blank" instead.</arg> </args> </function> ⤶ <example>⤶ <code>⤶ function draw.CustomCursor(panel, material)⤶ if panel and panel:IsValid() then⤶ -- Make the default cursor disappear⤶ panel:SetCursor("blank")⤶ ⤶ -- Paint the custom cursor⤶ local cursorX, cursorY = panel:LocalCursorPos()⤶ ⤶ surface.SetDrawColor(255, 255, 255, 240)⤶ surface.SetMaterial(material)⤶ surface.DrawTexturedRect(cursorX, cursorY, 20, 20)⤶ end⤶ end⤶ ⤶ local myPanel = vgui.Create("DFrame")⤶ -- ...⤶ ⤶ local customCursorMaterial = Material("vgui/your_cursor")⤶ ⤶ myPanel.Paint = function(s, w, h)⤶ draw.CustomCursor(s, customCursorMaterial)⤶ end⤶ </code>⤶ </example>⤶ ⤶ <upload src="5598e/8d7dfba5b02b2c7.png" size="5451" name="cursor.png" />⤶