Re: [MacPerl-Toolbox] Detecting email coordinates
[email protected] (Greenblatt & Seay) Thu, 30 Aug 2001 16:08:40 +0100
| Newsgroups | perl.macperl.toolbox |
|---|---|
| Message-ID | <l03110701b7b406686815@[207.91.2.213]> |
At 2:49 AM +0100 2001/08/29, Darryl Holder wrote:
>There is a script by Greenblatt & Seay titled "[MacPerl] Re: mouse detection"
>posted to the MacPerl mail list archive on 17 Jun 1999 at URL
>[http://bumppo.net/lists/macperl/1999/06/index.html] that I have modified and
>used in my GUI hacks.
Here's an updated version.
David Seay
http://www.mastercall.com/g-s/
#!perl
use Mac::Events;
use Mac::Events qw(@Event $CurrentEvent);
use Mac::LowMem;
use Mac::QuickDraw;
# my($flag);
$Event[mouseDown] = \&mouseDownHandler;
$Event[keyDown] = \&keyDownHandler;
print "Hold down the shift, control, option, and/or command keys and click
the mouse or press a key on the keyboard.
Type command period to quit.\n\n";
WaitNextEvent while !$flag;
sub mouseDownHandler {
$clk = LMGetMouseLocation();
($horz, $vert) = ($clk->h, $clk->v);
print "MOUSE CLICKED at Horizontal = $horz Vertical = $vert\n";
$modifiers = "";
$modKey = ($CurrentEvent->modifiers & 256);
if($modKey == 256) { $modifiers .= " command," }
$modKey = ($CurrentEvent->modifiers & 512);
if($modKey == 512) { $modifiers .= " shift," }
$modKey = ($CurrentEvent->modifiers & 1024);
if($modKey == 1024) { $modifiers .= " caps-lock," }
$modKey = ($CurrentEvent->modifiers & 2048);
if($modKey == 2048) { $modifiers .= " option," }
$modKey = ($CurrentEvent->modifiers & 4096);
if($modKey == 4096) { $modifiers .= " control," }
if ($modifiers) {
chop($modifiers);
print " MODIFIER KEYS = $modifiers";
}
print "\n\n";
}
sub keyDownHandler {
my($ev) = @_;
$k = chr($ev->character);
print "KEY = $k\n";
$modifiers = "";
$modKey = ($CurrentEvent->modifiers & 384);
if($modKey == 384) { $modifiers .= " command," }
$modKey = ($CurrentEvent->modifiers & 640);
if($modKey == 640) { $modifiers .= " shift," }
$modKey = ($CurrentEvent->modifiers & 1152);
if($modKey == 1152) { $modifiers .= " caps-lock," }
$modKey = ($CurrentEvent->modifiers & 2176);
if($modKey == 2176) { $modifiers .= " option," }
$modKey = ($CurrentEvent->modifiers & 4224);
if($modKey == 4224) { $modifiers .= " control," }
if ($modifiers) {
chop($modifiers);
print " MODIFIER KEYS = $modifiers";
}
print "\n\n";
if (($CurrentEvent->modifiers & 256) == 256 && $k eq ".") { $flag = 1 }
}
__END__