|
2 | 2 | on editorInitialize |
3 | 3 | set the editorMinWidth of me to 230 |
4 | 4 | set the editorMaxWidth of me to 0 |
5 | | - disable button "edit script" of me |
6 | | - disable button "inspect object" of me |
| 5 | + disable button "edit script" of me |
| 6 | + disable button "inspect object" of me |
7 | 7 | end editorInitialize |
8 | 8 |
|
9 | 9 | on editorUpdate |
@@ -127,12 +127,91 @@ on editorGoToObject |
127 | 127 | end editorGoToObject |
128 | 128 |
|
129 | 129 | on popupMenu |
130 | | - set the text of button "Menu" of me to "Select Behavior" & return & revIDEObjectSelectionMenu("", "button,stack") |
| 130 | + local tMenu, tObject |
| 131 | + |
| 132 | + put the cSelectedObjects of this stack into tObject |
| 133 | + |
| 134 | + put "Select Behavior" & return & revIDEObjectSelectionMenu("", "button,stack") into tMenu |
| 135 | + put return & "Create behavior from script only stack/|create behavior" after tMenu |
| 136 | + put return & tab & "Create stack with empty script/|create empty behavior" & return after tMenu |
| 137 | + if word 1 to -1 of the script of tObject is empty then |
| 138 | + put "(" after tMenu |
| 139 | + end if |
| 140 | + put tab & "Create stack using existing control script/|create behavior from script" after tMenu |
| 141 | + set the text of button "Menu" of me to tMenu |
131 | 142 | popup button "Menu" of me at the mouseLoc |
132 | 143 | end popupMenu |
133 | 144 |
|
134 | 145 | on menuPick pObject |
135 | | - set the itemdelimiter to "|" |
136 | | - put the last item of pObject into field 1 of me |
137 | | - valueChanged |
| 146 | + local tAction |
| 147 | + |
| 148 | + set the itemdelimiter to "|" |
| 149 | + put item -1 of pObject into tAction |
| 150 | + |
| 151 | + switch tAction |
| 152 | + case "create empty behavior" |
| 153 | + case "create behavior from script" |
| 154 | + local tError, tSuggestedName, tStackName |
| 155 | + local tTargetObject, tFilename, tStack |
| 156 | + |
| 157 | + put the cSelectedObjects of this stack into tTargetObject |
| 158 | + put revIDEStackOfObject(tTargetObject) into tStack |
| 159 | + put the effective filename of tStack into tDefaultFilename |
| 160 | + |
| 161 | + ask revIDELocalise("Please enter a name for the script only stack") with the short name of tTargetObject && "Behavior" |
| 162 | + if it is empty then exit menuPick |
| 163 | + put it into tStackName |
| 164 | + put word 1 to -1 of line 1 of tStackName into tStackName |
| 165 | + replace quote with "'" in tStackName |
| 166 | + |
| 167 | + if tDefaultFilename is not empty then |
| 168 | + set the itemDelimiter to "/" |
| 169 | + put tStackName & ".livecodescript" into the last item of tDefaultFilename |
| 170 | + else |
| 171 | + put tStackName & ".livecodescript" into tDefaultFilename |
| 172 | + end if |
| 173 | + |
| 174 | + ask file revIDELocalise("Please specify a location for the script only stack") with tDefaultFilename |
| 175 | + if it is empty then exit menuPick |
| 176 | + put it into tFilename |
| 177 | + |
| 178 | + lock messages |
| 179 | + create invisible stack tStackName |
| 180 | + close stack tStackName |
| 181 | + set the filename of stack tStackName to tFilename |
| 182 | + set the scriptOnly of stack tStackName to true |
| 183 | + |
| 184 | + if tAction is "create behavior from script" then |
| 185 | + set the script of stack tStackName to the script of tTargetObject |
| 186 | + end if |
| 187 | + |
| 188 | + save stack tStackName |
| 189 | + put the result into tError |
| 190 | + unlock messages |
| 191 | + |
| 192 | + if tError is empty then |
| 193 | + local tStackFiles |
| 194 | + |
| 195 | + set the behavior of tTargetObject to the long id of stack tStackName |
| 196 | + put the stackFiles of tStack into tStackFiles |
| 197 | + put tStackName & "," & tFilename into line (the number of lines of tStackFiles + 1) of tStackFiles |
| 198 | + revIDESetStackFilesProperty tStack, empty, tStackFiles |
| 199 | + |
| 200 | + if tAction is "create behavior from script" then |
| 201 | + set the script of tTargetObject to empty |
| 202 | + else |
| 203 | + edit script of stack tStackName |
| 204 | + end if |
| 205 | + end if |
| 206 | + |
| 207 | + if tError is not empty then |
| 208 | + answer error tError |
| 209 | + end if |
| 210 | + break |
| 211 | + |
| 212 | + default |
| 213 | + set the itemdelimiter to "|" |
| 214 | + put the last item of pObject into field 1 of me |
| 215 | + valueChanged |
| 216 | + end switch |
138 | 217 | end menuPick |
0 commit comments