Edit menu recipe?

Rob Cozens rcozens at pon.net
Fri Aug 20 09:05:56 CDT 2004


>Does anyone have an edit menu recipe they'd like to share?

Hi Frank,

Following is the script of the Edit button from revMenubar.rev:

on menuPick which
   global gREVChunkStore, gREVUndoList
   switch which
   case "Undo"
     if gREVUndoList is not empty then
       if line -1 of gREVUndoList is "width" then
         delete last line of gREVUndoList
         repeat for each line l in gREVUndoList
           put item 1 to -2 of l into tObject
           if there is a tObject then set the width of tObject to item -1 of l
         end repeat
       else
         delete last line of gREVUndoList
         repeat for each line l in gREVUndoList
           put item 1 to -2 of l into tObject
           if there is a tObject then set the height of tObject to item -1 of l
         end repeat
       end if
       put empty into gREVUndoList
     else
       undo
     end if
     break
   case "Cut Object(s)"
   case "Cut Objects"
   case "Cut Card"
   case "Cut"
   case "Cut Text"
     if the selectedField is not empty and the lockText of the 
selectedField then
       exit to top
     end if
     if the selectedField is not empty then
       put true into tField
       put the long id of the selectedField into tFieldID
     end if
     if revCheckGroupDelete() then
       cut
     end if
     if tField then
       if char 1 to 18 of revTargetStack(tFieldID) is "REVPropertyPalette" then
         put revTargetStack(tFieldID) into tStackName
         if the short name of this cd of stack tStackName is not among 
the items of "revBasic,revScript,revCustom" then
           --work around the object delete / crash bug
           lock screen
           put the selectedChunk into tRestore
           set the traversalOn of fld "hidden text" of stack 
"revMenuBar" to true
           select text of fld "hidden text" of stack "revMenuBar"
           paste
           select text of fld "hidden text" of stack "revMenuBar"
           copy
           set the traversalOn of fld "hidden text" of stack 
"revMenuBar" to false
         end if
       end if
     end if
     revUpdatePalette
     exit to top
     break
   case "Copy Objects"
   case "Copy Object(s)"
   case "Copy Card"
   case "Copy"
   case "Copy Text"
     if the selectedField is not empty then
       copy
       if char 1 to 18 of revTargetStack(the long id of the 
selectedField) is "REVPropertyPalette" then
         put revTargetStack(the long id of the selectedField) into tStackName
         if the short name of this cd of stack tStackName is not among 
the items of "revBasic,revScript,revCustom" then
           --work around the object delete / crash bug
           lock screen
           put the selectedChunk into tRestore
           set the traversalOn of fld "hidden text" of stack 
"revMenuBar" to true
           select text of fld "hidden text" of stack "revMenuBar"
           paste
           select text of fld "hidden text" of stack "revMenuBar"
           copy
           set the traversalOn of fld "hidden text" of stack 
"revMenuBar" to false
           do "select" && tRestore && "of stack" && quote & tStackname & quote
         end if
       end if
     else if (the selObj) is not empty then
       copy
     end if
     revUpdatePalette
     exit to top
     break
   case "Paste"
   case "Paste Object(s)"
   case "Paste Objects"
   case "Paste Text"
     write "starting paste" & cr to file "output"
     write "clipboard:" && the clipboard & cr to file "output"
     write "the selectedChunk:" && (the selectedChunk) & cr to file "output"
     write "gREVChunkStore:" && gREVChunkStore & cr to file "output"
     if the clipBoard is "text" and (the selectedChunk) is empty and 
(gREVChunkStore) is not empty then
       try
         write "paste 1" & cr to file "output"
         select gREVChunkStore
         write "paste 2" & cr to file "output"
         paste
         write "paste 3" & cr to file "output"
         --if pasting into the script editor, enable the Revert/Apply buttons
         put (the focusedObject) into tFocusedObject
         write "paste 4" & cr to file "output"
         put word 5 to -1 of tFocusedObject into tOwnerCard
         write "paste 5" & cr to file "output"
         --check the Script field of the script editor is focused
         write "paste 6" & cr to file "output"
         if the name of tFocusedObject is "field" &&quote&"Script"&quote \
             and the name of tOwnerCard is "card" &&quote&"revScript"&quote
         then send "rawKeyUp" to tFocusedObject
         write "paste 7" & cr to file "output"
         exit menuPick
       catch someError
         beep
         write "paste 8" & cr to file "output"
       end try
       write "paste 9" & cr to file "output"
       exit menuPick
     end if
     lock messages
     write "paste B1" & cr to file "output"
     set the defaultStack to the topStack
     write "paste B2" & cr to file "output"
     paste
     write "paste B3" & cr to file "output"
     unlock messages
     write "paste B4" & cr to file "output"
     if the clipBoard is "objects" then send "selectedObjectChanged" 
to btn "revBackScript" of stack "revLibrary"
     --exit to top
     write "finishing paste" & cr to file "output"
     break
   case "Clear Objects"
   case "Clear Card"
   case "Clear"
   case "Clear Text"
     set the defaultStack to the topStack
     if the selectedField is not empty then if the lockText of the 
selectedField then exit to MetaCard
     if revCheckGroupDelete() then delete
     break
   case "Deselect All"
     select empty
     break
   case "Select All"
     if the mode of the topStack is not 1 and the selectedField is empty then
       beep
       exit menuPick
     end if
     if the selectedField is not empty then
       if the lockText of the selectedField then exit to MetaCard
       select text of the selectedField
     else
       if the cantModify of the topStack then
         answer "This stack can't be modified"
         exit to MetaCard
       end if
       lock screen
       lock messages
       set the defaultStack to the topStack
       repeat with i = 1 to the number of layers
         if the visible of control i or the showInvisibles then
           if the selectGroupedControls then
             if word 1 of the name of control i is not "group" then
               set the selected of control i to true
             end if
           else
             set the selected of control i to true
             add the number of layers in control i to i
           end if
         else
           add the number of layers in control i to i
         end if
       end repeat
       unlock screen
       unlock messages
       send "selectedObjectChanged" to btn "revBackScript" of stack "revLibrary"
     end if
     break
   case "Invert Selection"
     if the mode of the topStack is not 1 and the selectedField is empty then
       beep
       exit menuPick
     end if
     lock screen
     lock messages
     set the defaultStack to the topStack
     repeat with i = 1 to the number of controls
       if (the visible of control i or the showInvisibles) and (not 
the selectGroupedControls or (the selectGroupedControls and word 1 of 
the name of control i is not "group")) then
         set the selected of control i to not the selected of control i
       end if
       if not the selectGroupedControls then add the number of layers 
in control i to i
     end repeat
     unlock screen
     unlock messages
     send "selectedObjectChanged" to btn "revBackScript" of stack "revLibrary"
     break
   case "Duplicate"
     set the defaultStack to revTargetStack(line 1 of (the selobj))
     if the selObj is not empty then
       lock screen
       lock messages
       put the number of lines in (the selObj) into tRepeatfor
       repeat for each line l in the selObj
         clone l
         if the right of last control > the right of this cd or the 
bottom of last control > the bottom of this cd then set the topLeft 
of last control to 10,10
       end repeat
       select empty
       put the number of controls into tNumberOfControls
       put tNumberOfControls - tRepeatFor+1 into tRepeatFor
       repeat with i = tNumberOfControls down to tRepeatFor
         set the selected of control i to true
       end repeat
       unlock messages
       unlock screen
       send "selectedObjectChanged" to btn "revBackScript" of stack "revLibrary"
     end if
     break
   case "Duplicate Card"
     set the defaultStack to revTargetStack(line 1 of (the selobj))
     clone the selobj
     break
   case "Replicate..."
     modal "revReplicate"
     break
   case "Select Grouped Controls"
     set the selectGroupedControls to not (the selectGroupedControls)
     if the selectGroupedControls and word 1 of (the selObj) is 
"group" then select empty
     break
   case "Intersected Selections"
     if the selectionMode is "intersect" then
       set the selectionMode to "surround"
       unhilite menuItem 15 of menu "Edit"
     else
       set the selectionMode to "intersect"
       hilite menuItem 15 of menu "Edit"
     end if
     break
   case "Preferences"
     modeless "revPreferences"
     break
   case "Find and Replace..."
     modeless "revSearch"
     break
   end switch
end menuPick

-- 

Rob Cozens
CCW, Serendipity Software Company

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)


More information about the use-livecode mailing list