Re: [MACTCL] catching quit from Wish menu
by Tim Jones other posts by this author
Feb 28 2007 10:00AM messages near this date
Re: [MACTCL] catching quit from Wish menu
|
Re: [MACTCL] catching quit from Wish menu
Sorry for top-posting, but this is short -
Does someone have access to add Jon's detailed sample to the tclAE
doc pages? While I've not been troubled by this (as I've not tried
to use it), I can now see excellent purposes for AppleEvents that I'd
not previously considered just by reviewing the code presented.
Tim
On Feb 28, 2007, at 10:06 AM, Jon Guyer wrote:
> Here's a solution, adapted from what Alpha does, that should be
> reasonably robust (most of it is comments):
>
>
> proc MyAeHandler {theAppleEvent theReplyAE} {
> # extract the direct object, which holds the file(s) we're to
> open
> set pathDesc [::tclAE::getKeyDesc $theAppleEvent ----]
>
> # if we didn't get an AE list, make one
> if {[tclAE::getDescType $pathDesc] ne "list"} {
> set pathDesc [::tclAE::coerceDesc $pathDesc list]
> }
>
> set count [::tclAE::countItems $pathDesc]
>
> set paths [list]
>
> # iterate through the AE list of files and build a list of paths
> for {set item 0} {$item < $count} {incr item} {
> set fileDesc [::tclAE::getNthDesc $pathDesc $item]
>
> # convert whatever we got into an 'alis' AEDesc object
>
> set alisDesc [::tclAE::coerceDesc $fileDesc alis]
>
> # convert the 'alis' to a path
> # better to convert to 'utf8', but a coercion handler isn't
> # available for that
>
> lappend paths [::tclAE::getData $alisDesc TEXT]
>
> # a more modern solution might be to convert to 'furl'
> # rather than 'alis', but then the URL needs to be parsed
>
> # a robust solution would provide coercion handlers from all
> # possible argument types ('fss ', 'alis', 'furl',
> 'TEXT', 'utf8', etc.)
> # and convert them to a single type that we want to deal
> with.
> #
> # the right way is with ::tclAE::installCoercionHandler,
> not by
> # adding switches here
> }
>
> foreach path $paths {
> if {[file exists $path] && $::ready} {
> after idle [list FileOpen $path]
> }
> }
> }
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Tcl-mac mailing list
tcl-mac@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-mac
Thread:
Alastair Davies
Philip Aker
Robert Karen
Jon Guyer
Jeff Hobbs
Jon Guyer
Jeff Hobbs
David Zolli
Jon Guyer
Tim Jones
Jon Guyer
David Zolli
Jon Guyer
Jon Guyer
Jeff Hobbs
Robert Karen
Kevan Hashemi
David Zolli
Kevin Walzer
Jeff Hobbs
Robert Karen
Jon Guyer
Robert Karen
Kevin Walzer
Jon Guyer
Robert Karen
Robert Karen
Tim Jones
Robert Karen
Jon Guyer
Kevin Walzer
Jim Ingham
Jasper Taylor
Clarke
|