WidgetSetCursor

Syntax

Success = WidgetSetCursor(Widget, Cursor)

Description

Sets the mouse cursor shape that should be displayed when the pointer hovers over the specified widget.

Parameters

Widget
The handle of the ProGUI widget.

Cursor
The desired cursor constant. Possible values:

#PG_Cursor_Default         : Standard arrow cursor.
#PG_Cursor_Cross           : Crosshair cursor.
#PG_Cursor_IBeam           : Text input I-beam cursor.
#PG_Cursor_Hand            : Pointing hand cursor (used for links).
#PG_Cursor_Busy            : Hourglass or spinning cursor indicating busy state.
#PG_Cursor_Denied          : "Not allowed" or "stop" cursor.
#PG_Cursor_Arrows          : Four-way arrow cursor (move).
#PG_Cursor_LeftRight       : Two-way horizontal arrow cursor (horizontal resize).
#PG_Cursor_UpDown          : Two-way vertical arrow cursor (vertical resize).
#PG_Cursor_LeftUpRightDown : Two-way diagonal arrow (top-left to bottom-right resize).
#PG_Cursor_LeftDownRightUp : Two-way diagonal arrow (bottom-left to top-right resize).
#PG_Cursor_Invisible       : Hides the cursor.

Return Value

Returns #True if the cursor type was successfully set for the widget, or #False if the widget handle or cursor constant was invalid.

Remarks

ProGUI automatically manages setting the cursor when the mouse enters or leaves a widget based on this property. If the mouse is currently over the widget when this function is called, the cursor will update immediately.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 400, 200, "Widget Cursor Example")
RootLayout = WindowGetLayout(MyWindow)
LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
LayoutSetPadding(RootLayout, 10)

If MyWindow
  ; Widget with default cursor
  Widget1 = CreateWidget(0, 0, 100, 30)
  WidgetSetClass(Widget1, "widget1")
  WidgetSetMargin(Widget1, 5)
  ; WidgetSetCursor(Widget1, #PG_Cursor_Default) ; Default

  ; Widget with hand cursor
  Widget2 = CreateWidget(0, 0, 100, 30)
  WidgetSetClass(Widget2, "widget2")
  WidgetSetMargin(Widget2, 5)
  WidgetSetCursor(Widget2, #PG_Cursor_Hand)

  ; Widget with cross cursor
  Widget3 = CreateWidget(0, 0, 100, 30)
  WidgetSetClass(Widget3, "widget3")
  WidgetSetMargin(Widget3, 5)
  WidgetSetCursor(Widget3, #PG_Cursor_Cross)

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

#PG_Event_MouseEnter, #PG_Event_MouseLeave

Supported OS

Windows, Linux