At 7:24 am -0800 05/03/02, [EMAIL PROTECTED] (Axel Rose) wrote:
>Category: None
>Group: None
>Status: Open
>Resolution: None
>Priority: 5
>Submitted By: Axel Rose (axelrose)
>Assigned to: Nobody/Anonymous (nobody)
>Summary: crash with Copy or Cut, TE?
>
>Initial Comment:
>I experience a Bus Error after just pressing Cmd-C and
>a PowerPC access exception using Cmd-X while running
>the following sample program
>
>(taken from a post to the mailing list by Alan Fry - I
>do not fully understand the internals and found this just
>by playing with MacPerl)

The machine will certainly crash with X, C, V (and the Menu Bar 
equivalents) under these circumstances but this is NOT a bug in 
MacPerl.

When a TextEdit field is opened (as in the 'tutorial' script below) 
it is necessary to establish handlers for 'Cut', 'Copy' and 'Paste' 
which point to the TextEdit functions "TECut HTE" etc., where 'HTE' 
is the handle to the new TextEdit field.

When the script below is run, the existing Menu Bar 'Cut', 'Copy' and 
'Paste' call functions which point to >MacPerl's Editor's< TextEdit 
fields, not those appertaining to the script. Hence the crash.

The same problem arises with 'MacDialogs' for instance which will 
occasion visits to the bowels of MacBugs for the same reasons.

In all cases where a script establishes new TextEdit fields the Menu 
Bar must be modified, appointing handlers for 'Cut', 'Copy' and 
'Paste' appropriate to the new TextEdit fields. The management of the 
Menu Bar can become quite tricky because the program must keep an eye 
on which MacPerl window is front-most and ensure the right Menu Bar 
is installed for that window at all times.

Alan Fry


>#!perl -w
>use strict;
>
>use Mac::Events;
>use Mac::QuickDraw;
>use Mac::TextEdit;
>use Mac::Windows;
>
>my $win =
>   MacWindow->new( Rect->new( 50, 50, 550, 290 ), "Text Console", 1,
>     floatProc, 1 );
>SetPort $win->window;
>$win->sethook( 'redraw', \&do_draw );
>
>my $viewRect = $win->window->portRect;
>my $destRect = OffsetRect( $viewRect, 10, 10 );
>
>my $hTE = TENew( $destRect, $viewRect );
>TESetText( "sample text", $hTE );
>
>WaitNextEvent while $win->window;
>dispose $win;
>TEDispose($hTE);
>
>sub do_draw {
>     my ($win) = @_;
>     TEActivate($hTE);
>     TEGetText($hTE);
>     TEUpdate( $viewRect, $hTE );
>}
>

Reply via email to