Re: How group picture box and text box in quark 4.11
Re: How group picture box and text box in quark 4.11
- Subject: Re: How group picture box and text box in quark 4.11
- From: Hans Haesler <email@hidden>
- Date: Wed, 11 Dec 2002 15:36:32 +0100
On Wed, 11 Dec, Elmer Banate wrote:
>
Can anyone help me how to group picture box and text
>
box. I have a script that will import picture and make
>
a text box below the figure. But I can't group them.
Hi Elmer,
from looking at your code I guess that you're using "ScriptMaster XT".
I don't have it. But from what I've heard it is... evil.
Here is how you can do the job with vanilla Quark commands.
You should begin by deselect a possible selection. And on each iteration
you should use this same command: 'set selection to null'. Else all new
boxes will end up grouped.
You use 'set tool mode to drag mode'. But this should happen before the
repeat loop begins. No point of repeating it over and over.
Since you make the picture box and the text box 'at beginning', you can
select them simply by:
---
set selected of picture box 1 to true
set selected of text box 1 to true
---
You set the variables 'topbounds' and 'rightbounds' but you don't use
them later. And the swapping of the values can be simplified.
To group the boxes, I have tried to use 'select menu item ...' but it
failed. So I use here another trick. Anyway: both have to be called
outside of the 'tell document 1' block so there is a call to a handler
for grouping them.
The list of files might contain other files than importable images.
Even if you're sure that there are only image files in the source folder
then it is likely that the invisible 'icon' leaves a picture box empty.
The 'try' wrapper in my script is just there for decoration, because
a file which can't be imported will not throw an error.
To make sure that the files are images you could ask for their file
types. Here I use another trick for making sure that the top-most picture
box contains an image: ask for the bounds. If the result is {0, 0, 0, 0}
then the handler for importing the image is called again. The counter
'ctr' is incremented and the script tries to compose the next file path.
If there is an error, then this means that there are no more files, the
top-most picture box is deleted and the script is stopped.
---
global ctr
global fldr
global grfxfldr
tell application "QuarkXPress 4.11"
activate
set selection to null
tell document 1
set fldr to choose folder with prompt "Now select your graphics folder."
set grfxfldr to list folder fldr
set tool mode to drag mode
set ctr to 0
repeat with i from 1 to count items of grfxfldr
make picture box at beginning with properties {bounds:{0, 0, "12p", "12p"}}
tell picture box 1
my importFile()
set {y1, x1, y2, x2} to bounds as list
set {y1, y2} to {(y2 as real) + 6, (y2 as real) + 30}
end tell
make text box at beginning with properties {bounds:{y1, 0, y2, x2}}
my groupBoxes()
end repeat
end tell
end tell
on importFile()
set ctr to ctr + 1
try
set file_name to (fldr & item ctr of grfxfldr) as string
on error
tell document 1 of application "QuarkXPress 4.11"
delete picture box 1
end tell
error number -128
end try
tell document 1 of application "QuarkXPress 4.11"
tell picture box 1
try
set image 1 to alias file_name
end try
if bounds of image 1 is {0, 0, 0, 0} then
my importFile()
end if
end tell
end tell
end importFile
on groupBoxes()
tell application "QuarkXPress 4.11"
tell document 1
set selected of picture box 1 to true
set selected of text box 1 to true
set x to object reference of every generic box whose selected is true
end tell
set selection to item 1 of x
set selection to null
end tell
end groupBoxes
---
This works for me.
---
Hans Haesler <email@hidden>
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.