Programmer Reference : Common Graphics : Using cursors : Changing the color of a cursor
Changing the color of a cursor
The color of a cursor can be changed by sending the recolorCursor:backgroundColor: message to a CgCursor object. The color arguments are specified using CgRGBColor objects. Class CgRGBColor is described in more detail in "Specifying colors". The following example illustrates how to recolor a font cursor so that the foreground is red and the background is blue.
| window cursor red blue |
window := self shell window.
"Create and recolor the cursor."
cursor := CgDisplay default createFontCursor: XCWatch.
red := CgRGBColor red: 65535 green: 0 blue: 0.
blue := CgRGBColor red: 0 green: 0 blue: 65535.
cursor recolorCursor: red backgroundColor: blue.
"Display the cursor."
window defineCursor: cursor.
(Delay forSeconds: 5) wait.
window undefineCursor.
cursor freeCursor
Some platforms, such as Windows, do not support color cursors.
Last modified date: 01/29/2015