I'm using a Tk::Tree to display a two-legel heirarchal datastructure. I
use
$tree = $treeframe->Scrolled( 'Tree',
-scrollbars => 'oe',
-height => 40,
-width => -1,
-browsecmd => \&tree_browsecmd,
-command => \&tree_command,
# -closecmd => \&tree_closecmd,
# -opencmd => \&tree_opencmd,
pack( -expand => 1, -fill => 'both', -side => 'top', );
to create a scrollable Tree. Notice that the open and close callbacks are commented out.
I then add each top-level item like this:
$tree->add( $key, -text => $top_data );
also adding each sub-item like this:
$tree->hide( 'entry', # sub-items collapsed at start
$tree->addchild(
$key,
-text => $sub_data,
)
);
before finally declaring the top-level item "openable" like so:
$tree->setmode( $key, 'open' );
Okay, on MainWindow, I get a good Tk::Tree displayed with the top-level
data listes with a little [+] to the left. If I press the [+] the tree
branch opens up to list all the sub-items and the [+] becomes a [-]. If I click the [-] the tree branch closes up again. Opening and closing the
branch does NOT fire my callbacks, because they are commented out of the
call to the constructor.
If I double-click an item (top- or sub-level) my &tree_command() callback fires (it's just a stub at the moment, as are all the callbacks).
Now, suppose I UN-comment the open and close callbacks, and re-run the
proggy. Now, clicking [+] and [-] fire the open and close callbacks
(still only stubs) as expected.. but the tree branch DOES NOT open and
close as before. Perldoc says "Specifies a command to call whenever an
entry needs to be opened/closed [...] If the -opencmd/-closecmd option is
not specified, the default opening action is to show all the child entries
of the specified entry."
By specifying my own callbacks, I have disabled whatever default callbacks were defined. I need to know how to trigger the default callbacks from
within my own callbacks so that my &tree_opencmd() and &tree_closecmd() callbacks can do useful things *as*well*as* open/close the branch of the
tree. I'd like the &tree_command() callback to also be able to open/close
the tree branch as well.
Anyone know how to get hold of, and later invoke, the default callbacks?
---
þ Synchronet þ Programatically generated on The ANJO BBS