I have a canvas with a chart, a bar chart, and a grid background. Or maybe
that is more accurately described as a canvas with a grid and a bar chart
on top of it. It seems to me that whatever is drawn last becomes "on top"
of everything else.
And there is a "floating" canvas label that displays some data in a much more evident way.
I have managed to make that chart "scrollable" left and right. I use the arrow keys for that. But when I scrolled, the floating label would be pushed off the right edge of the screen. I fixed that:
proc scrollchart {leftright} {
lassign [$::chart xview] x1 x2
if {$leftright == "left"} {
$::chart xview moveto [expr $x1 - 0.0005]
set ::toplabel_x [expr $::toplabel_x - 10]
}
if {$leftright == "right"} {
$::chart xview moveto [expr $x1 + 0.0005]
set ::toplabel_x [expr $::toplabel_x + 10]
}
That works very well. The label flickers a little, but it stays put.
But there is also this:
bind $::chart <B1-Motion> {%W scan dragto %x %y 1}
That works to the extent that I can indeed drag the chart left and right
with the mouse pointer, but then the floating label gets dragged too, which
I obviously don't want.
Maybe there is some code I could use to compensate for the movement like I did in the scrollchart proc, but then I think, everything would be so much easier if I could anchor some elements to some edge or corner of the visible screen rather than to the canvas' hard coordinates.
I am struggling with that concept. Can someone please shed some light?
--
Luc
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)