Skip to content

Instantly share code, notes, and snippets.

@cocoaNib
Created September 14, 2016 08:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cocoaNib/867865dc6aaafa1ca9ba4bd8222e21aa to your computer and use it in GitHub Desktop.
Save cocoaNib/867865dc6aaafa1ca9ba4bd8222e21aa to your computer and use it in GitHub Desktop.
Copy and paste of text does not work in a Director 12 Projector. Workaround
Attach this behaviour to a text-member
-- ==============================================
-- Textfieldcursor
--
-- ==============================================
global gTextFieldClipBoard
global gTextFieldSelectedText
property spriteNum, spriteMember
on beginSprite me
spriteMember = sprite(spriteNum).member
end
on mouseEnter me
cursor(1)
end
on mouseLeave me
cursor(0)
end
on mouseUp me
if (sprite(spriteNum).member.selectedText.text <> "") then
gTextFieldSelectedText = sprite(spriteNum).member.selectedText.text
-- put gTextFieldSelectedText
end if
end
-- ATTENTION !!!
--
-- DIRECTOR 12 COPY AND PASTE
-- THIS WORKAROUND ONLY WORKS IN A PROJEKTOR !!!
--
on keyDown me
-- a = select all
if (the commandDown and the keyCode = 0) then
gTextFieldSelectedText = sprite(spriteNum).member.text
num = member(spriteMember).text.char.count
the keyBoardFocusSprite = sprite(spriteNum)
member(spriteMember).selection = [0,num]
else
-- c = copy
if (the commandDown and the keyCode = 8) then
gTextFieldClipBoard = gTextFieldSelectedText
else
-- v = paste
if (the commandDown and the keyCode = 9) then
pasteFolieTextFieldClipBoard me
else
-- x = ausschneidem
if (the commandDown and the keyCode = 7) then
clipboardCut me
else
pass
end if
end if
end if
end if
sprite("sprFolienNummer").member.editable = false
end
on clipboardCut me
whichSelection = member(spriteMember).selection
if whichSelection[1] + 1 <> whichSelection[2] then
gTextFieldClipBoard = spriteMember.selectedText.text
delete member(spriteMember).char[whichSelection[1] + 1..whichSelection[2]]
end if
end
on pasteFolieTextFieldClipBoard me
charCount = gTextFieldClipBoard.char.count
whichSelection = member(spriteMember).selection
num1 = whichSelection[1]
num2 = whichSelection[2]
if num1 <> num2 then
if num1 = 0 then
member(spriteMember).char[1..num2] = gTextFieldClipBoard
else
member(spriteMember).char[(num1 + 1)..num2] = gTextFieldClipBoard
end if
else
if num1 = 0 then
x = member(spriteMember).char[1]
member(spriteMember).char[1] = gTextFieldClipBoard & x
else
x = member(spriteMember).char[num1]
member(spriteMember).char[num1] = x & gTextFieldClipBoard
end if
end if
end if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment