Hi folks,
I wonder if anyone else has encoutered this behaviour, and if they found a work-around.
Basically I have a script that copies selected text boxes onto a newly created layer. However this doesn’t work perfectly. If I have four text boxes, the loop will iterate four times but frequently a text box will be ‘found’ twice. One of the reasons I set a text box to be ‘unselected’ is an attempt to prevent this duplicated selection.
There’s a number of display dialog statements in this code, as I’m trying to understand why Quark is being so mischievous. At a guess maybe the transfer to another layer is causing the problems but it does seem a bit silly to have two loops, one loop to find the selected boxes, and another to move these selected boxe to the new layer.
Any thoughts, or advice, gratefully received.
local numSelected
local strLayer, strSelected
set newLayer to "Battenburg Cake"
tell application "QuarkXPress"
tell document 1
-- Find if any text boxes are selected
set numSelected to (count of (text boxes where selected is true))
if (numSelected is less than 1) then -- if a text box isn't selected, display this warning, and return.
display dialog "You must select one text box"
return
else -- we have text boxes selected
make new layer at end with properties {name:newLayer}
--display dialog ("We selected " & numSelected & " boxes ")
repeat with tb from 1 to (text box count)
tell text box tb
-- set strValue to story 1
-- display dialog (strValue)
if (selected is true) then
--display dialog ("This text box " & tb & " is selected")
set strLayer to layername
set strSelected to "yes"
set selected to false
else
set strLayer to "none"
set strSelected to "no"
end if
end tell
--display dialog ("Details: " & tb & ": " & strLayer & ": " & strSelected & " text box count " & (text box count))
if strSelected is equal to "yes" then
move text box tb of layer strLayer to beginning of layer newLayer
end if
end repeat
end if
end tell
end tell -- end of the work with the application