Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
Director Crash on opening a cursor - Valentina
Semi-Random Bezier Animatior
Add a unique property to a property list
Director 8.5 Studio
Pulling in Those Graphics
Ripple General Settings-Alphamania
Saving Data in Shockwave
Inspect
BlurImage
HTML-ingo
 

 

 

Behavior Cut, Copy, Paste behavior 1.1

Added on 6/10/1999

 

Compatibilities:
behavior D6_5 Mac PC

This item has not yet been rated

Author: RettCrocker

Copy and Paste Text

property pMember

on beginSprite me
  set lSprite = the spriteNum of me
  set pMember = the memberNum of sprite lSprite
end

on keyDown
  set lKey = the key
  set lFlag = 0
  if the machineType = 256 then
    if the controlDown then
      set lFlag = 1
    end if
  else
    if the commandDown then
      set lFlag = 1
    end if
  end if
  if NOT lFlag then
    PASS
    return -1
  end if
  case lKey of
    "c":
      mCopySelection
    "x":
      mCopySelection
      mDeleteSelection
    "v":
      mDeleteSelection
      mPasteSelection
  end case
end

on mCopySelection me
  set lStart = the selStart
  set lEnd = the selEnd
  if lStart <> lEnd then
    set lTempMember = findEmpty(member 1)
    duplicate member pMember, lTempMember
    delete char (lEnd + 1) to (length(field lTempMember)) of field lTempMember
    delete char 1 to lStart of field lTempMember
    copyToClipboard member lTempMember
    erase member lTempMember
  end if
end

on mDeleteSelection me
  set lStart = the selStart
  set lEnd = the selEnd
  if lStart <> lEnd then
    delete char (lStart + 1) to lEnd of field pMember
    set the selStart to lStart
    set the selEnd to lStart
  end if
end

on mPasteSelection me
  set lStart = the selStart
  set lTempMember = findEmpty(member 1)
  pasteClipBoardInto member lTempMember
  set lText = chars(field pMember, 1, lStart) & field lTempMember & chars(field pMember, (lStart + 1), length(field pMember))
  put lText into field pMember
  erase member lTempMember
end

on getBehaviorDescription
  set lText = ""
  put "--======= Cut, Copy, Paste behavior =======--" & RETURN after lText
  put "This behavior, when added to an editable field " after lText
  put "sprite, gives this field the standard edit " after lText
  put "functionality one would expect from a text " after lText
  put "field.  In other words, selecting some text " after lText
  put "in the field and hitting CMD-C (or CTRL-C on " after lText
  put "Windows) copies the selected text to the " after lText
  put "clipboard.  Likewise, pasting and cutting also " after lText
  put "act as expected.  Give it a try.  You"ll " after lText
  put "like it." & RETURN & RETURN after lText
  put "As always, if you use this behavior I would " after lText
  put "like a mention in your credits.  Enjoy." & RETURN & RETURN after lText
  put "/// © Rett Crocker 1997 \" & RETURN after lText
  put "\ r3tt@mindspring.com ///" & RETURN after lText
  return lText
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail