I'm trying to handle a right-click event on individual elements of a tree (Tk::Tree):
$tree->bind('<3>', sub{print "right click"});
The above works fine, but it applies to the entire tree, no matter where you click. What if I add elements like so:
$tree->add("test1", -text => "TEST 1");
$tree->add("test2", -text => "TEST 2");
$tree->add("test3", -text => "TEST 3");
How can I bind events to the individual branches of the tree, so that if a user right-clicks on just the "TEST 2" branch, I can handle it separately?
I assume the same would apply to any list as well. Is there a way to bind events to individual list elements?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.