Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Tree in Perl/tk

1 view
Skip to first unread message

pit

unread,
Oct 15, 2009, 4:53:43 AM10/15/09
to
Hi Folks,

I've a question about working with a Scrolled Tree in Perl/Tk. I want
to detect if an entry of the tree is visible in the window (i.e after
opening the indicator) ?

TIA
Pit

Q...@invalid.net

unread,
Oct 17, 2009, 11:47:39 AM10/17/09
to

pit <pharr...@am-soft.de> wrote in message-id: <1439f7cb-eff2-4d61...@o10g2000yqa.googlegroups.com>


The following two HList methods may produce the data you need.

*$hlist*->info(anchor)
Returns the entryPath of the current anchor, if any, of the
HList widget. If the anchor is not set, returns the empty
string.

*$hlist*->infoBbox(*$entryPath*)
Returns a list of four numbers describing the visible
bounding box of the entry given *$entryPath*. The first two
elements of the list give the x and y coordinates of the
upper-left corner of the screen area covered by the entry
(specified in pixels relative to the widget) and the last
two elements give the lower-right corner of the area, in
pixels. If no part of the entry given by index is visible on
the screen then the result is an empty string; if the entry
is partially visible, the result gives the only the visible
area of the entry.

Something like (untested):
my @allEntryPaths = $treeWidget->info();
foreach my $entryPath (@allEntryPaths) {
my @entryIsVisible = $treeWidget->infoBbox($entryPath);
if ($entryIsVisible[0]) {
#entry is visible, the list should contain $x1,$y1,$x2,$y2
}
}

hth,
Jason

0 new messages