i'm using the list manager to print some files in a nice maclike way. I have an array of files which come in diffrent types and i have a hash which holds their types, so that $type{$file} gives back a number aquivalent to the type.
I'm able to handle the window and the basic list stuff so that i could print the files in different TypeFaces according to their type.
So i have my list:
my $list = $win->new_list( Rect->new(0, 0, 484, 300), Rect->new(0, 0, 1, scalar @Files), Point->new(0, 13), \&draw_it, 1, 1 );
and the subroutine:
sub draw_it {
my($msg, $select, $rect, $cell, $file, $list) = @_;
return unless $msg == lDrawMsg || $msg == lHiliteMsg; my($where) = AddPt($rect->topLeft, $list->indent); EraseRect $rect;
TextFace($style{$type{$file}}); LSetSelect(0, $cell, $list);
MoveTo($where->h, $where->v); DrawString &basename($file);
return;
}
That is working as far as i understood it and tested it. Now i wanted to give the user the possibility to change the filetype by clicking on the filename in the window. So i tried:
if ( $select && ($type{$file} eq MAINFILE) ) {
$type{$file} = INPUTFILE;
}
('MAINFILE' and 'INPUTFILE' are constants, btw) and it seems to do what i want but if i also include the case for changing the second type:
if ( $select && ($type{$file} eq MAINFILE) ) {
$type{$file} = INPUTFILE;
} elsif ( $select && ($type{$file} eq INPUTFILE) ) {
$type{$file} = MAINFILE;
}
it is doing nothing if i click on a filename. I checked the tarzipme droplet which comes with MacPerl because something similiar is done there for manual conversion of the files but i don't understand how it is done there.
The whole script is rather long so i hope someone with more experience can tell me what to do without having a complete example. I also checked the 'MoreMacintoshToolbox.pdf' to understand better what the ListManager is doing but at the moment i'm still just reading instead of really understanding ;-)
Best regards Martin
-- Alles Vernuenftige ist einfach; alles Komplizierte ist ueberfluessig. -- M. Kalaschnikow