NewCursor = CocoaMessage(0, 0, "NSCursor alloc")ĬocoaMessage(0, NewCursor, "initWithImage:", = CocoaMessage(0, 0, "NSCursor arrowCursor")ĬompilerCase #PB_OS_Windows. Gdk_window_set_cursor_(gtk_widget_get_window(WindowID(0)), NewCursor)ĬompilerCase #PB_OS_MacOS. NewCursor = gdk_cursor_new_(#CURSOR_ARROW) NewCursor = gdk_cursor_new_(#CURSOR_BUSY) If EventGadget() = 0 And EventType() = #PB_EventType_LeftClickĬompilerCase #PB_OS_Linux. But you should be warned that Apple won't like or approve this.
So now you are able to display a wait cursor on MacOS X in 32 and 64 bit programs.
On MacOS now this image is read in with CatchImage() to display an hourglass as wait cursor while on Linux and Windows the default cursor images are used. I have simply loaded the PNG image of a classic Windows hourglass from Wikipedia and converted it to data in a DataSection. Nevertheless I have tried to find a cross-platform solution which allows you to toggle between the normal arrow cursor and a busy cursor. While one application is unresponsive, typically other applications are usable in the meantime. Users can choose to terminate an unresponsive application, by using "Force Quit" under the Apple menu, the keystroke command-option-escape, or the Force Quit command found by control-clicking (or right-clicking) the icon of an unresponsive application in the Dock. This prevents the user from closing, resizing, or even minimizing the windows of that application, however moving the window is still possible in OS X and previously hidden parts of the window are usually redrawn even when the application is unresponsive. This is meant to indicate that the application is temporarily unresponsive, a state from which the application may recover, however it may also indicate that the application has entered an unrecoverable state or an infinite loop. If an application takes longer than 2 seconds to process the events in its event queue (regardless of the exact cause) the operating system displays the wait cursor whenever the cursor hovers over that application's windows. This works as follows:Įach application has an event queue that receives events from the operating system (For example key presses and mouse button clicks). Wikipedia for Spinning_pinwheel wrote:The display of the wait cursor is controlled by the operating system, not by the application. As soon as the cursor enters the "Arrow" or "Busy" button again, the arrow cursor will be restored and will only be changed to the busy cursor when not hovering over a button! On Windows the cursor image is NOT immediately changed when the "Busy" button is pressed but when the cursor is moved away from the button. On Linux and MacOS the cursor image is changed as soon as the "Busy" button is pressed. OpenWindow(0, 100, 100, 300, 200, "Change Mouse Cursor")Īnother potential problem about which a user of these routines should be aware is the different behaviour after pressing the "Busy" button:
Gdk_window_set_cursor_(gtk_widget_get_window(WindowID(WindowID)), SetClassLongPtr_(WindowID(WindowID), #GCL_HCURSOR, Procedure SetCursor(WindowID.I, CursorID.I) I also spotted a small mistake in the Linux part: you should replace Since your current example is based on the Carbon framework it doesn't work when compiled on MacOS X for 64 bit because the Carbon framework was never ported by Apple from 32 to 64 bit. For the Cocoa framework I already demonstrated this totally different example which unfortunately misses the busy cursor (you should also read the following postings).
With PB 5.00 the Mac version of PureBasic was completely reprogrammed and based on the current Cocoa framework.
Unfortunately your link to my MacOS code from June 2011 points to old code for the Carbon framework when PureBasic was solely based on the (from Apple now deprecated) Carbon framework. I know from my own hard learned experience that it's necessary to test all cross-platform code on all platforms in x86/圆4/ASCII/Unicode modes to detect mistakes which I would never had expected. Unfortunately your current solution has some problems (especially on MacOS). Thank you very much for trying to create a cross-platform routine to change the mouse cursor.