Programmer's Reference

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
Note:
Some platforms, such as OS/2 PM and Windows, do not support color cursors.


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