hwtk::chooseentitycolor

Opens an anonymous editor dialog to return a user-specified color. This function halts execution of the current thread until the editor is dismissed or a color is picked.

Format

hwtk::chooseentitycolor - pathName ?option value? …

Standard Options

-clientdata
Database name: clientData
Database class: ClientData
Acts as a data storage for a widgets. User can store any data and this will not have any effect on widget property.

Widget Specific Options

-array
Array to place hexadecimal, integer, and RGB value equivalents of user’s selected color into. Values are indexed with names hexa, integer, and rgb, respectively.
-command
Database name: command
Command to execute when a color is selected by the user. The value of the selected color can be passed to the specified command with the substitutions %R, %I, and %H for RGB, Integer, or Hexadecimal values, respectively.
-initialcolor
Sets the initially highlighted color in the editor.
-parent
Sets the parent widget of the editor. Defaults to root.
-startindex
Either 0 or 1, indicates the index of the first color value. For example, if the 3rd color is picked and -startindex is set to 0, then its integer value will be 2.
-values
A list of integer values that specifies what corresponding colors are visible when the widget appears.
-x
Sets the x value of the location that the editor initially appears at.
-y
Sets the u value of the location that the editor initially appears at.

Example

proc onColorSelect {colorInt colorRgg colorHex} { 
    puts "\nSelected Color:"
    puts "RGB:         $colorInt"
    puts "Integer:     $colorRgb"
    puts "Hexadecimal: $colorHex"
    return true
}

set curX [winfo pointerx .]
set curY [winfo pointery .]
set initColorVals [list 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 31]

hwtk::chooseentitycolor -startindex 0 -values $initColorVals -initialcolor 15 -command {onColorSelect %I %R %H} -x $curX -y $curY