- Fedora 27 x86 with Gnome 3 and PB 5.46 x86 in ASCII and Unicode mode with GTK3 (for GTK2 take a look into Update 2 below)
- Kubuntu 18.04 x86 with KDE and PB 5.46 x86 in ASCII and Unicode mode with GTK2 and GTK3
- Linux Mint 18.3 x64 'Sylvia' with Cinnamon and PB 5.46 x64 in ASCII and Unicode mode
- MacOS 10.6.8 'Snow Leopard' with PB 5.46 x86 in ASCII and Unicode mode
- Windows 7 x64 with PB 5.46 x86 and x64 in ASCII and Unicode mode
Code: Select all
EnableExplicit
CompilerIf #PB_Compiler_OS = #PB_OS_Linux
#GDK_BLANK_CURSOR = -2
ImportC ""
gtk_widget_get_window(*Widget.GtkWidget)
EndImport
CompilerEndIf
Procedure HideCursor(HideCursor.I = #True)
Protected Cursor.I
CompilerSelect #PB_Compiler_OS
CompilerCase #PB_OS_Linux
If HideCursor
Cursor = gdk_cursor_new_(#GDK_BLANK_CURSOR)
Else
Cursor = 0
EndIf
gdk_window_set_cursor_(gtk_widget_get_window(WindowID(0)), Cursor)
CompilerCase #PB_OS_MacOS
If HideCursor
CocoaMessage(0, 0, "NSCursor hide")
Else
CocoaMessage(0, 0, "NSCursor unhide")
EndIf
CompilerCase #PB_OS_Windows
If HideCursor
ShowCursor_(#False)
Else
ShowCursor_(#True)
EndIf
CompilerEndSelect
EndProcedure
OpenWindow(0, 200, 100, 200, 100, "Hide cursor demo")
ButtonGadget(0, 30, 20, 140, 25, "Hide cursor")
CreateStatusBar(0, WindowID(0))
AddStatusBarField(#PB_Ignore)
StatusBarText(0, 0, "Press <Esc> to show cursor", #PB_StatusBar_Center)
AddKeyboardShortcut(0, #PB_Shortcut_Escape, 0)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
If EventGadget() = 0 And EventType() = #PB_EventType_LeftClick
HideCursor(#True)
DisableGadget(0, #True)
EndIf
Case #PB_Event_Menu
If EventMenu() = 0
HideCursor(#False)
DisableGadget(0, #False)
EndIf
EndSelect
ForEver
Code: Select all
Cursor = gdk_cursor_new_(#GDK_ARROW)
Code: Select all
Cursor = 0
Update 2: In order to run the example on the Linux distribution Fedora 27 x86 with Gnome 3 and GTK2 you have to add the following declarations to the ImportC..EndImport block:
Code: Select all
gdk_cursor_new(CursorType.L)
gdk_window_set_cursor(*GdkWindow, *Cursor.GdkCursor)