The Mouse Cursor

   

Practical Programming in Tcl & Tk, Third Edition
By Brent B. Welch

Table of Contents
Chapter 38.  Color, Images, and Cursors


graphics/tip_icon.gif

The cursor attribute defines the mouse cursor. Example 38-6 shows the cursors that come built into Tk:

Example 38-6 The Tk cursors.

graphics/38fig02.gif

A foreground and background color for the cursor can be specified. Here are some example cursor specifications:

 $w config -cursor watch            ;# stop-watch cursor $w config -cursor {gumby blue}     ;# blue gumby $w config -cursor {X_cursor red white} ;# red X on white 

The other form for the cursor attribute specifies a file that contains the definition of the cursor bitmap. If two file names are specified, then the second specifies the cursor mask that determines what bits of the background get covered up. Bitmap editing programs like idraw and iconedit can be used to generate these files. Here are some example cursor specification using files. You need to specify a foreground color, and if you specify a mask file, then you also need to specify a background color:

 $w config -cursor "@timer.xbm black" $w config -cursor "@timer.xbm timer.mask black red" 

The cursors shown in Example 38-6 are available on all platforms. However, on Windows and Macintosh some of the cursors are mapped to native cursors and appear differently. On Windows the following cursors are mapped to native cursors: arrow, ibeam, icon, crosshair, fleur, sb_v_double_arrow, sb_h_double_arrow, center_ptr, watch, and xterm. These additional cursors are defined on Windows: starting, size, size_ne_sw, size_ns, size_nw_se, size_we, uparrow, and wait. On Windows, use the no cursor to eliminate the cursor. On Macintosh, the following cursors are mapped to native cursors: ibeam, xterm, cross, crosshair, plus, watch, arrow. These additional cursors are defined on Macintosh: text and cross-hair.


       
    Top
     



    Practical Programming in Tcl and Tk
    Practical Programming in Tcl and Tk (4th Edition)
    ISBN: 0130385603
    EAN: 2147483647
    Year: 1999
    Pages: 478

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net