David Seay asked... >>Can the modifier keys be detected without another key being pressed on the >>keyboard? >> >>sub mouseDown_Handler { >> print "MOUSE DOWN\n"; >> if (($CurrentEvent->modifiers & 2176) == 2176) { print "\b (OptionKey)\n" } >>} Alan Fry replied... >It shoud be just 'modifiers & 2048' I think. > >sub mouseDown_Handler { > if (($CurrentEvent->modifiers & 2048) == 2048 ) { > print "MOUSE DOWN with Opt key\n" > } > else { print "MOUSE DOWN\n" } >} > Thanks Alan! If no modifier keys are depressed '$CurrentEvent->modifiers' returns '128' when a key is pressed but returns '0' when the mouse is clicked, thus the difference between '2176' and '2048' when the option key is down in the above examples. The script at the end of the message helps demonstrate this. Are there other situations where '$CurrentEvent->modifiers' returns something? Next question... can a MacPerl program detect if a modifier key is depressed while no other keyboard or mouse actions occur? For instance, suppose I want a droplet when executed to perform one subroutine if the option key is down and another if the option key is up. Last question (for now)... can an event be passed on after it has been handled in a MacPel script so that the operating system or MacPerl itself can also decide whether to act on it? Unlike scripts that don't handle events like this the script below must check for "command period" so it knows when to stop. In Hypertalk an event can be passed on for further handling, so I wondered if it could be done in MacPerl. This list and its participants are wonderful! Thanks, David Seay http://www.mastercall.com/g-s ------------------------------ #!perl use Mac::Events; use Mac::Events qw(@Event $CurrentEvent); use Mac::LowMem; $Event[keyDown] = \&keyDown_Handler; $Event[mouseDown] = \&mouseDown_Handler; print "Type a key while depressing the shift, control, option, and/or command keys, then click the mouse while depressing the same modifier key(s). Type command period to quit.\n\n"; WaitNextEvent while !$flag; sub keyDown_Handler { my($ev) = @_; $k = chr($ev->character); $modKey = ($CurrentEvent->modifiers); print "KEY DOWN = $k MODKEY = $modKey\n\n"; if ($modKey == 256 && $k eq ".") { $flag = 1 } # COMMAND '.' TO QUIT } sub mouseDown_Handler { $modKey = ($CurrentEvent->modifiers); print "MOUSE CLICKED MODKEY\t= $modKey\n\n"; } ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch