I am a new Perl user and this is my first post to the MacPerl list. Please bear with me. I decided that I wanted to learn how to use Quickdraw (and by consequence windows.pm and events.pm) and that the best way to do this was to write some applications using QuickDraw. I realize now this might have been a fools errand as I have little experience with the mac toolbox and Perl code for doing this doesn''t really make for easy reading. I wrote a short program to write box outlines as the user drags around the window and then print a box with a pattern in it after he lets go of the mouse - much as is done in virtually every quickdraw based painting program. I handled this with Mac::Events using 1) mousedown, mouseup, getting the cursor position and converting it to local window coordinates; 2) checking to see if the mouse is still down (so as to draw the outline rectangle); 3) checking for mouse up to draw the final box. My code is primitive and is really meant just as a learning device for myself. It can only be stopped using command-period. I realize that events drawn into a window might normally have to be handled in the screen redrawing routine or some such thing in order to be permanent. My Question Is: Is there a way to use these Mac::Events features to read mouse activity without deactivating all of the rest of the mouse functions? In this script although I can draw boxes I cannot drag the window or use the close box, grow box, or zoom box. I would rather not reprogram all of this functions into subroutines for each and every mouse event. Is there someway to carry out the mousing functions I want without losing all of the other mouse event features? Here is the Code: _____________________________________________________ #!perl use strict; use Mac::LowMem; use Mac::QuickDraw; use Mac::Windows; use Mac::Events;use Mac::Events; use Mac::Events qw(@Event $CurrentEvent); my ($love,$win,$clk,$horz,$vert,$hOrigin,$vOrigin,$h1,$v1,$shape,); $Event[mouseDown] = \&mouseDown_Handler; $Event[mouseUp] = \&mouseUp_Handler; $love = new Pattern q{ .XX.XX.. XXXXXXX. XXXXXXX. .XXXXX.. ..XXX... ...X.... ........ ........ }; # everyones favorite pattern $win = new MacWindow ( new Rect (130, 143, 500, 500), #set window with these coordinates ' Demo', #window title 1, documentProc, #window type 1, ); while ($win->window) { #while window exists WaitNextEvent(); } END { $win->dispose() if (defined($win)); #dispose of windows upon ending } sub mouseDown_Handler { SetPort $win->window; # I beleive this sets the graphics port to the window $clk = LMGetMouseLocation(); #get the location of the mouse down (global coordinates $clk = GlobalToLocal($clk); #translate it into loca window coordinates ($horz, $vert) = ($clk->h, $clk->v); #convert horizontal and vertical coordinates to these $hOrigin = $horz; #this will be the origin of the first click $vOrigin =$vert; $shape = Rect->new($hOrigin, $vOrigin, $horz, $vert); RGBForeColor(new_color(0, 50000, 50000));# aqua while ( StillDown() ) { $h1=$horz;$v1=$vert; #set to old mouse coordinates SetPort $win->window; $clk = LMGetMouseLocation(); #get new mouse coordinates $clk = GlobalToLocal($clk); #convert to local window coordinates ($horz, $vert) = ($clk->h, $clk->v); #set new mouse coordinates if (($h1 !=$horz) && ($v1 !=$vert)) #Are the new coordinates diff from the old ones? { RGBForeColor(new_color(65535, 65535, 65535));# white-couldn't find a better way to erase! FrameRect( Rect->new($hOrigin, $vOrigin, $h1, $v1)); #erase old Rectanlge outline FrameRect( $shape); RGBForeColor(new_color(0, 50000, 50000));# aqua Draw new rectangle outline $shape = Rect->new($hOrigin, $vOrigin, $horz, $vert); #use new mouse coordinates FrameRect($shape); } else { #if they are the same mouse coordinates don't bother erasing RGBForeColor(new_color(0, 50000, 50000));# aqua FrameRect($shape);} } } sub new_color # a color choosing nicety I got off of this board { bless(\pack('SSS', @_[0..2]), 'RGBColor'); } sub mouseUp_Handler { # If the mouse is released fill the rectangle with hearts RGBForeColor(new_color(0, 50000, 50000));# aqua FrameRect(Rect->new($hOrigin, $vOrigin, $horz, $vert)); FillRect(Rect->new($hOrigin, $vOrigin, $horz, $vert), $love); } __END__ _____________________________________________________ Thanks, Ilir # ===== Want to unsubscribe from this list? # ===== Send mail with body "unsubscribe" to macperl-request@macperl.org