This behavior, when placed on a NON-EDITABLE filed will allow the user to select and copy the text to the clipboard. This also works in Shockwave.
--Copyright 1999 Chuck Neal
--chuck@mediamacros.com
--If you find this code helpful, send me an e-mail and let me know. :-)
property spriteNum, startChar, endChar
global currentField
on mouseDown me
sendAllSprites(#clearSelection)
cursor 1
currentField = spriteNum
startChar = the mouseChar
endChar = the mouseChar
(the actorList).add(me)
end
on stepFrame me
if endChar <> the mouseChar then
endchar = the mouseChar
if endChar > startChar then
sprite(spriteNum).member.char[startChar..endChar].hilite()
else if endChar < startChar then
sprite(spriteNum).member.char[endChar..startChar].hilite()
else
theLines = sprite(spriteNum).member.line.count
sprite(spriteNum).member.line[theLines + 1].hilite()
end if
end if
end
on mouseUp me
cursor -1
if endChar > startChar then
sprite(spriteNum).member.char[startChar..endChar].hilite()
else if endChar < startChar then
sprite(spriteNum).member.char[endChar..startChar].hilite()
else
theLines = sprite(spriteNum).member.line.count
sprite(spriteNum).member.line[theLines + 1].hilite()
end if
if (the actorList).getOne(me) <> 0 then
(the actorList).deleteOne(me)
end if
end
on mouseUpOutside me
cursor -1
if endChar > startChar then
sprite(spriteNum).member.char[startChar..endChar].hilite()
else if endChar < startChar then
sprite(spriteNum).member.char[endChar..startChar].hilite()
else
theLines = sprite(spriteNum).member.line.count
sprite(spriteNum).member.line[theLines + 1].hilite()
end if
if (the actorList).getOne(me) <> 0 then
(the actorList).deleteOne(me)
end if
end
on copySelected me
if startChar < endChar then
theSelection = sprite(spriteNum).member.char[startChar..endChar]
else
theSelection = sprite(spriteNum).member.char[endChar..startChar]
end if
--create temp member
tempMember = new(#field)
tempmember.text = theSelection & " "
copyToClipboard tempMember
erase tempMember
end
on clearSelection me
theLines = sprite(spriteNum).member.line.count
sprite(spriteNum).member.line[theLines + 1].hilite()
end
on endSprite me
if (the actorList).getOne(me) <> 0 then
(the actorList).deleteOne(me)
end if
end
on getBehaviorDescription me
describe = "This behavior alows non-editable field members to copy text to the clipboard. This is not a variable, it actually writes to the Mac/Windows clipboard so the data is available to other fields as well as other programs." & return
describe = describe & "Note- this will only work with field members, not text members. Also note that using command/Ctrl + C in authoring mode will not work, as Director will intercept these events."
describe = describe & return & "Call the copy function using... sendSprite(x, #copySelected)"
return describe
end
Contact
MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA