As far as the "active fill" not working is concerned, it's because you have "-state =>'disabled' in their setup. That makes them essentially 'inactive'. If you are looking for a way to change their colors on "enter and leave", you need to setup a binding on each small rect or tag them.

That brings up a big point you are missing. Tags!! I'm not sure what you are trying to accomplish exactly, but you make no use of tags, and you need to. I like to use hashes instead of arrays, and with that in mind, here is a script which may help you understand things. You have to play around with it a bit, to get the hang of it. I took the group out, since it was just getting in the way. Show us a full working script which uses the group, if you want us to help you with it.

#!/usr/bin/perl use warnings; use strict; use Tk; my $mw = MainWindow->new(); # first create a canvas widget my $c = $mw->Canvas(width => 300, height => 200)->pack(); my $x1 = 10; my $x2 = 20; my $parent = $c->createRectangle(10, 20, 100, 60, -fill => 'red', -tags => ['parent'], ); my %children; for my $i (1..4) { $children{$i} = $c->createRectangle($x1, 20, $x2, 30, #-state =>'disabled', -activefill => 'green', -disabledfill => 'white', -tags => ['children',$i], ); $x1 += 15; $x2 += 15; } my $ebutton = $mw->Button(-text => 'Exit', -command => 'Tk::exit')->pack(); $c->Tk::bind("<Motion>", \&get_info ); MainLoop(); sub get_info{ my $curr_object = $c->find('withtag','current'); if(defined $curr_object){ print "curr->",@$curr_object,"\n"; #array dereference my (@list) = $c->gettags($curr_object); print "list->@list\n"; } }

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Tk-Canvas Grouping by zentara
in thread Tk-Canvas Grouping by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.