Date: Mon, 13 Nov 1995 20:22:56 +1000 From: Grant Young <gyoung@SCU.EDU.AU> Subject: SCRIPTS 4 U:Standard Text OperationsHiya folks,
I posted a question a while back regarding Director's handling of standard text operations (i.e. cut, paste, copy and undo) to find out if it was an anomoly with my copy of DFM not allowing these operations in a text field set to editable.
The non-reply lead me to believe that this was a problem with Director, and that nobody had needed these functions, or wasn't telling me how to get around it ;)
So I wrote my own :)
Now if someone tells me that there is a way, and I didn't check checkbox x in dialogue y, I don't mind, 'cause I learnt something. (BTW, if there is a way, I'd still like to know ;) )
But to cut a long story short, I decided to give them to the direct-l community :) They are free to use in anything, and they are posted below. If anyone has any improvements (and I'm sure that they can be improved!) all I ask is that you let me know, and when I have what I feel is the most efficient way of achieving the desired results (i.e. copy, cut, paste and undo) I will post it.
Until then, enjoy! and please don't make me feel really small if this was a stupid excercise :/
See ya, grant.
PS : these scripts alsao check for a mousedown on all of the active text sprites, in order to determine which field is active.
on changeField -- called from a mouseDown script on the text cast members used
global gActiveField
put the clickon into spriteNum
put spriteNum into gActiveField
end changeField
on pasteText
pasteClipBoardInto cast 100
-- user defined cast member (don't call by name, as pasteClipboardInto
-- replaces the entire castmember - script, name and all!)
put field 100 into insertText
insert(insertText)
end pasteText
on copyText
put the selection into field "copyText"
copyToClipBoard cast "copyText"
end copyText
on cutText
global gActiveField
put field "xyz" into field "UndoText1"
-- where "xyz" is the name of the cast member. repeat for all
-- text cast members used
if gActiveField = x then
put "xyz" into fieldName
else if gActiveField = y then
etc...
-- repeat for all text cast members used
put the selStart into insertPoint
put the selEnd into endPoint
put (endPoint - insertPoint) into theRange
if theRange > 0 then
put the selection into field "copyText"
copyToClipBoard cast "copyText"
put field fieldName into editTemp
repeat with i = 1 to theRange
delete char (insertPoint + 1) of editTemp
end repeat
put editTemp into field fieldName
else
nothing
end if
end cutText
on undoText
put field "xyz" into field "TempText1"
put field "UndoText1" into field "xyz"
put field "TempText1" into field "UndoText1"
end undo
on clearFields
put field "xyz" into field "UndoText1"
put "" into field "xyz"
-- repeat for all text cast members used
end clearFields
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
g r a n t y o u n g
_____________________________________
p r o j e c t d e v e l o p m e n t
v i r t u a l s t u d i o s
_____________________________________
lismore n s w australia
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~