Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi all,
I'm trying to Bind to a tag on text on a canvas with no luck.
I can use CanvasBind to bind to the entire canvas and print the message but I can't bind to blue colored text which it what I want.
Find my code below.
$canvas->bind("blue", "<Enter>", [ sub { print "hi" }]);
As usual thanks in advance for the help.
-Mark

Replies are listed 'Best First'.
Re: Binding to a tag on text on a canvas
by kelan (Deacon) on Sep 25, 2003 at 21:05 UTC

    Remember that bind takes as its first argument either the ID of an item, or a tag name. Unless you have have actually given all blue colored items the tag "blue", the bind won't work. Tags are not based on any item properties, but are just arbitrary text strings that you assign yourself. Use the addtag method of Canvas to add tags to items.

    kelan


    Perl6 Grammar Student