I first thought of sending e-mail directly to Dr.Csaba Namethi to ask
this but I posted it here to share the information.
In my application I implemented a context menu (pop-up menu) which can
be called via right mouse click on the cell to enable users to call
column dependent procedures. The column only shows the short overview
or description of complex information, which can be defined in an
extra dialog that can be called from the context menu.
If the current cell / column is editable, it is apparently visible
where I am now. The background of the selected cell would be changed
in to the one defined by -selectbackground. However, as I set the
cell / column non-editable due to the reason above, it is hard to find
to make sure if the cell was really clicked or was recongized by the
program properly. Or users cannot find a certain menu line in context
menu which they expect.
Could somebody give me neat ideas?
At the end of my post, I want to mention my thanks to Dr.Csaba Namethi
for his great contribution.
Sachito
You can proceed like in the following examle, in which $tbl and $menu
denote a tablelist widget and a menu, respectively:
bind [$tbl bodytag] <Button-3> [list postPopupMenu $menu %W %x %y %X %Y]
proc postPopupMenu {menu W x y X Y} {
# Get the index of the cell just clicked
foreach {tbl _x _y} [tablelist::convEventFields $W $x $y] {}
set cellIdx [$tbl containingcell $_x $_y]
foreach {row col} [split $cellIdx ","] {}
if {$row < 0 || $col < 0} {
return ""
}
# Undo the last cell highlighting, if any
set lastPopupCellIdx [$tbl attrib "lastPopupCell"]
if {$lastPopupCellIdx ne ""} {
$tbl cellconfigure $lastPopupCellIdx -background "" \
-selectbackground "" -selectforeground ""
}
# Highlight the clicked cell and remember its index
$tbl cellconfigure $cellIdx -background yellow \
-selectbackground yellow -selectforeground black
$tbl attrib "lastPopupCell" $cellIdx
# Post the pop-up menu
tk_popup $menu $X $Y
}
Notice how the "attrib" subcommand of the Tcl command associated with a
tablelist widget can be used to store and retrieve arbitrary
widget-specific data. Here we use an attribute whose name is
"lastPopupCell" and whose value is the index of the cell from which the
pop-up menu was last posted.
--
Csaba Nemethi http://www.nemethi.de mailto:csaba....@t-online.de
First of all, I am truely sorry that I mistyped your name.
Now I just tried your idea to use attrib command, it works exactly I
have expected!
I get visible "selected" information also on the non-editable cell.
I thank you very much!
Sachito