|
-- clipboard functions
for fields and text members
-- Dank für's Debugging an Johann de Vries
property spritenum, myMem, myClipBoardOut, myClipBoardIn
on beginsprite me
myMem = sprite(spritenum).member
-- bei Text pasting generiert d7 #text
myClipBoardIn = new(#text)
--
-- MS Word etc. erkennt text nur, wenn #field kopiert
wurde
myClipBoardOut = new(#field)
--
end
on enterFrame
member("dbg").text = string(member(myMem).selection)
end
on copyText me
-- in die Zwischenablage kopieren
start = member(myMem).selection[1] + 1
stop = member(myMem).selection[2]
if stop = 0 then
member(myClipBoardOut).text = EMPTY
copyToClipboard member myClipBoardOut
else if start = stop+1 then
member(myClipBoardOut).text = EMPTY
copyToClipboard member myClipBoardOut
else
member(myClipBoardOut).text = member(myMem).char[start..stop]
copyToClipboard member myClipBoardOut
return [start, stop]
end if
end
on cutText me
-- in die Zwischenablage ausschneiden
sel = copyText(me)
if listp(sel) then
delete member(myMem).char[sel[1]..sel[2]]
end if
end
on pasteText me
start = member(myMem).selection[1]
stop = member(myMem).selection[2]
put start
-- Zwischenablage einfügen
pasteClipboardInto member myClipBoardIn
mtype = member(myClipBoardIn).type
-- nötig, falls innerhalb des Films kopiert wird
if mtype = #text OR mtype = #field then
if myClipBoardIn.text <> ""
then
(myClipBoardOut).text = member(myClipBoardIn).text
-- wenn sich der cursor am Anfang
des Textes befindet
if start = 0 then
if start <>
stop then
put
(myClipBoardIn).text into (myMem).char[1..stop]
else
put
(myClipBoardIn).text before member(myMem)
end if
else
if start <>
stop then
put
(myClipBoardIn).text into (myMem).char[start+1..stop]
else
put
(myClipBoardIn).text after (myMem).char[start]
end if
end if
else
alert "Es befindet sich
kein Text in der Zwischenablage" & RETURN & ¬
"(" & string(member(myClipBoardIn).type)
& ")"
end if
end if
end
on selectall me
len = member(myMem).text.length
member(myMem).selection = [0,len]
end
on keydown me
-- Standard-Shortcuts filtern
if the commandDown then
case the key of
"c":
copyText me
"x":
cutText me
"v":
pasteText me
"a":
selectall me
otherwise
put "!"
end case
else
pass
end if
end
on endsprite me
-- temporäre Darsteller löschen
erase member myClipBoardOut
erase member myClipBoardIn
end
|