#!/usr/bin/perl -w use strict; use Tk; use Tk::ROText; my $mw; # Main Window my $fview; # Text box (Read only) # Create Main Window and textbox $mw = new MainWindow; $fview = $mw->Scrolled( 'ROText', -scrollbars => "oe", -cursor => "hand2" ); $fview->pack; # Print "Root" Folder $fview->insert('end', "\n"); $fview->insert('end', "Root" , "Root"); $fview->insert("Root.last", "\n", "Root_newline"); # Hover over $fview->tagBind("Root", "" => [ \&hover, "Root", 1 ]); # Hover out $fview->tagBind("Root", "" => [ \&hover, "Root", 0 ]); # Double click $fview->tagBind("Root", "" => [ \&dclick, "Root", 0 ]); # Wait For Christmas! MainLoop; # make folder hot! sub hover { shift; my $tag = shift; my $do = shift; if ($do == 1) { $fview->tagConfigure($tag, -foreground => "red" ); } elsif ($do == 0) { $fview->tagConfigure($tag, -foreground => "black" ); } } # expand folder sub dclick { shift; my $tag = shift; my @folders; my $fullpath; @folders = ( "Linux", "Mail", "Perl" ); foreach my $folder (@folders) { $fullpath = "/$folder"; # Hover over $fview->tagBind($fullpath, "" => [ \&hover, $fullpath, 1 ]); # Hover out $fview->tagBind($fullpath, "" => [ \&hover, $fullpath, 0 ]); # Diplay the folder link $fview->insert( 'Root_newline.last', $folder, $fullpath ); $fview->insert( $fullpath.".last", "\n", $fullpath."_newline" ); } } #### $w->bind("tag", '<1>', [ \&bind, "one", "two" ]); sub stuff { my @a = @_; my $i = 0; print "Callback received this stuff:\n"; for (@a) { print "\targ($i) : $_\n"; $i++ } }