[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [MacPerl] Glue: Report from the field
At 15.51 -0400 1999.06.14, Mat Marcus wrote:
>It would be convenient to have the POD display which properties are
>read-only. Also, there is no indication of the allowable elements. Finally,
>the name of the inherited class could be useful here. All of these are
>available in Script Editor's view of the dictionary.
Good ideas, I will look into it.
>I wonder if it would be possible to apply verbs to AEObjDescs as well as to
>Glue e.g.:
>
> $doc1 = $myGlue->obj(document=>1);
> $doc1->set($myGlue->obj(property=>'name'), to=>'newName');
>
>This would allow direct translation of the original version of the
>AppleScript.
Hm. I just got rid of AEObjDesc for the next version! :) The only reason
why was that they no longer had a use. I can add them back in. But I
would need to make sure that any descs the glue returns are AEObjDescs.
Not a problem, I think. AEObjDesc objects would all be like this:
bless {DESC => $desc, GLUE => $self}, 'AEObjDesc';
Then $objdesc->{GLUE} could provide all the info I need. I might have to
save this for the next version, though.
>Anyway, my first attempt looked something like this:
>
> use Mac::Glue;
> use Mac::Files;
> use Mac::Types;
> use Mac::AppleEvents::Simple;
>
> $i = new Mac::Glue 'InDesign';
>
> $mySpreadSpec = $i->obj(property=>'active_spread',
>property=>'active_window');
> #$myPlacedObjectSpec =
>$i->place("System:Code:Shuksan:QA:TestFile:art1.tif", on=>$mySpreadSpec);
>
>Here I encountered my next problem. Noting that the 'place' verb expects an
>FSSpec as it's first parameter I tried passing a plain old string as in
>AppleScript. The application did receive an FSSpec. But it was invalid.
>Apparently the string was being directly stuffed into the FSSpec's fields.
Odd. It works for me, using various events that ask for an fss. Hm. I
tried it in the last release (19990607) and it doesn't work. Oh well, it
does now. :) Or, it will in the next release.
> $myPlacedObjectSpec = $i->place(MacPack('fss
>',"System:Code:Shuksan:QA:TestFile:art1.tif"), on=>$mySpreadSpec);
>
>This worked. Maybe this is a service that Glue could easily provide?
That is what I do, basically. Detect an fsspec is wanted, and pack it.
>the next line. The 'place' verb returns a reference to an object. However I
>found it difficult to use $myPlacedObjectSpec in a glue expression. My first
>naive approach was to try:
>
> #$i->set($i->obj(property=>'geometric_bounds', $myPlacedObjectSpec ),
>to=>["6p0", "6p0", "18p0", "18p0"]);
>
>This didn't work. After examining the Glue source code I happened on this
>hack:
>
> $myBlessedObjectSpec = bless {DESC=>$myPlacedObjectSpec}, 'AEObjDesc';
> $i->set($i->obj(property=>'geometric_bounds', $myBlessedObjectSpec ),
>to=>["6p0", "6p0", "18p0", "18p0"]);
>
>Perhaps Glue could do this blessing for me when an object reference is
>returned?
Previously only AEObjDescs could be passed in like that. I changed it so
you could pass in AEDescs or AEObjDescs, but then only AEDescs once I
removed AEObjDesc. I think in preparation for using object descriptors as
targets, I will put AEObjDesc back in, and you can pass either an AEDesc or
an AEObjDesc in here.
>P.S. One more thing. I couldn't get this to translate:
>
>##Applescript:
>tell application "Indesign"
> name of document 1 -- this works fine
>end tell
>
>##Perl:
>
>use Mac::Glue ':glue';
>use Mac::Files;
>use Mac::Types;
>use Mac::AppleEvents::Simple;
>
>
>$i = new Mac::Glue 'InDesign';
>print $i->get($i->obj(property=>'name', document=>1));
>print $^E;
>
>This prints -1728.
Hm. Odd. I have no idea why, but that too is broken in the last release,
but works in my current version (using BBEdit as the target). Odd indeed.
Oh well, I have it working now, so I won't worry about why it was broken
before. When i do a diff for the version history, maybe I'll take a look
and see if I can find out.
Thanks very much for your feedback, and I hope I've addressed your concerns
satisfactorily. I may or may not do the doc fixes in the next release, but
I will add in AEObjDesc, though I won't make it the target this time around
(unless I get on a roll tonight :).
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
===== Want to unsubscribe from this list?
===== Send mail with body "unsubscribe" to macperl-request@macperl.org