[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] ListManager in MacDialog porblem



Dear MacPerl Gurus,

This is a plea for help.

I am working on an application where I need to use a list in a dialog.
The users must be able to edit list entries, and I can't find a
TextEdit.pm module.

I wrote the code at the end of this message (derived from the code in
MacLists.pm) to add a list to a MacDialog, then wrote a small handler
and installed it using the "item_hit" method.
However, I can't get the item handler to (1) use the "MacList::click"
method to track the mouse (for one thing, at runtime it seems to think
$Mac::Events::CurrentEvent is undefined and so can't access modifiers),
then (2) get the selection so I can put the text into the field for
editing.

I also wrote a filterproc to save the event to a global variable, so it
would be available to the itemhandler.  Even though I have imported
Mac::Events with all the variables, $Mac::Events::CurrentEvent is not
visible from within the debugger at this time. This may be a bug.

Any help you could provide in getting a working handler that would deal
with lists embedded in MacDialogs would be greatly appreciated. While I
have moved away from modal dialogs in my normal Mac programming, I don't
feel up to writing the code to support TextEdit in MacPerl just yet.

Thanks in advance,
Frank Alviani

#
# Handlers
#
sub ListHandler {
	local $where = GlobalToLocal $gMyEvt->where;
	my ($isDouble);
	my ($selCell);

	$isDouble = LClick($where, $gMyEvt->modifiers, $list->{list});
	$selCell = LGetSelect(0, new Point(0,0), $list->{list});
	$OK = 1;
}

#!perl
########################################################################
#####
# Allows lists to be added to dialogs, ala MacWindow
########################################################################
######

package MacDialog;

BEGIN {
    use Carp;
    use Mac::Lists;
}

=item new_list [CLASS, ] LIST

=item new_list [CLASS, ] itemNo, dataBounds, cSize, theProc, [, drawIt
[, hasGrow [, scrollHoriz [, scrollVert]]]]

Create a new list, attach it to the dialog, and return it. In the first
form, 
registers an existing list. In the second form, calls  C<LNew>, getting
the
rectangle from the indicated item in the item list.

=cut
sub new_list {
    my($my) = shift @_;		#get "self", a MacDialog
    my($type) = @_;
    my($class,$list);

	if ($type =~ /^\d+/) {	#should be item-no
        $class = "MacList"
    } else {
        $class = shift @_;
        $type  = $_[0];
    }
    if (ref($type) eq "ListHandle") {
        $list = $type;
    } else {
	   my($iNo) = shift @_;
       my(@pre_) = splice(@_, 0, 3);
	   my($box) = $my->item_box($iNo);
       $list    = LNew($box, @pre_, $my->{port}, @_) or croak "LNew
failed";
    } 
    $class->new($my, $list);
}


1;

__END__



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch