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

Re: [MacPerl] Still looking for examples



Thank you VERY much.  My program is now totally working as I had planned! 

-
nghai


>At 12.28 1998.03.13, nghai wrote:
>>I'm still trying to find examples that would help me with the use of
>>Mac::Menus and Mac::Events particularly for the following:
>>
>>  Mac::Menus - To create a custom menubar where items will invoke Perl
>>subroutines
>
>In :MacPerl Ä:ext:Mac:Menus:t: there is a nice example.
>
>>  Mac::Events - To check if a modifier key (ctrl/cmd/opt/shift) is
>>currently being depressed.
>
>OK.  Set an event handler for your window:
>
>  $win->sethook('key', \&handle_keys);
>
>Then your handle_keys sub:
>
>  sub handle_keys {
>    my($my, $v) = @_;
>    my($mod) = $Mac::Events::CurrentEvent->modifiers();
>    if ($v == 119 && ($mod & cmdKey()) eq cmdKey()) {
>      $my->dispose();
>    }
>  }
>
>Now, I suck at bitmask stuff (darn liberal arts education), so someone
>PLEASE tell me if I got the ($mod & cmdKey()) part right or wrong.  But it
>seems to work, so what of it?  :)
>
>Anyway, this checks if cmd-w is pressed, at the moment that "w" is actually
>pressed.  If it is, it closes the window.


_________________________________________________________________________
Hai Ng
"Virtual Tools for the Real World"


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