Programmer's Reference

Platform cursors

You can map font cursors to correspond to a platform's built-in cursors by sending mapFontCursor:platformCursor: to a CgDisplay object. In the following example, the symbol #wait is defined as a key that maps to the current platform's wait cursor. You can use any object as a key. The cursor is created using createFontCursor: and displayed in a window. Note that constants from the PlatformConstants pool dictionary are used.

| window platform key cursor |
window := self shell window.
 
"Determine what the current platform is and set the constant name
 specifying the platform's wait cursor."
platform := System subsystemType: 'CG'.
(#('WIN' 'WIN32s' 'WIN-NT') includes: platform)
    ifTrue: [key := 'IdcWait'].
platform = 'PM' ifTrue: [key := 'SptrWait'].
platform = 'X' ifTrue: [key := 'XCWatch'].
 
"Look up the constant and define a font cursor that maps to the
 platform's wait cursor."
window display
    mapFontCursor: #wait
    platformCursor: (PlatformConstants at: key asPoolKey).
 
"Create a font cursor which maps to the platform's wait cursor."
cursor := window display
    createFontCursor: #wait.
 
"Display the cursor."
window defineCursor: cursor.
(Delay forSeconds: 5) wait.
window undefineCursor.
 
"Free the cursor."
cursor freeCursor.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]