From e1f48ffcfd130fdc448813de11c82a847651ead4 Mon Sep 17 00:00:00 2001 From: Kamikaze Date: Fri, 12 Mar 2021 16:35:34 -0500 Subject: [PATCH] [add] the Ctrl key has to be held down. The Ctrl key has to be held down for the plugin to work. This is so that it does not conflict when the user is implementing a dragDorp in their project. --- frlDragDropFilesIntoIDE.livecodescript | 840 +++++++++++++------------ 1 file changed, 425 insertions(+), 415 deletions(-) diff --git a/frlDragDropFilesIntoIDE.livecodescript b/frlDragDropFilesIntoIDE.livecodescript index b2abbb1..d915a29 100644 --- a/frlDragDropFilesIntoIDE.livecodescript +++ b/frlDragDropFilesIntoIDE.livecodescript @@ -59,680 +59,690 @@ constant kTextPlan = "json,html,htm,txt,lng,locale,log,mnu,nfo,inf,ini,inc,bar,c constant kLiveCodeExtension = "lce" on extensionInitialize - if the target is not me then - pass extensionInitialize - end if - - if the environment is "development" then - insert the script of me into front - set the _ideoverride of me to true - end if + if the target is not me then + pass extensionInitialize + end if + + if the environment is "development" then + insert the script of me into front + set the _ideoverride of me to true + end if end extensionInitialize on extensionFinalize - if the target is not me then - pass extensionFinalize - end if + if the target is not me then + pass extensionFinalize + end if - remove the script of me from front + remove the script of me from front end extensionFinalize on dragEnter - if the dragData["files"] is not empty - then _acceptDrop + if the controlKey is not "down" then pass dragEnter + if the dragData["files"] is not empty + then _acceptDrop - pass dragEnter + pass dragEnter end dragEnter on dragMove - if the dragData["files"] is not empty - then _acceptDrop + if the controlKey is not "down" then pass dragMove - pass dragMove + if the dragData["files"] is not empty + then _acceptDrop + + pass dragMove end dragMove on dragLeave - if there is not a stack sMouseStack or within(stack sMouseStack, globalLoc(the mouseLoc)) is false - then _deleteBackgroundGraphic + if the controlKey is not "down" then pass dragLeave + + if there is not a stack sMouseStack or within(stack sMouseStack, globalLoc(the mouseLoc)) is false + then _deleteBackgroundGraphic - pass dragLeave + pass dragLeave end dragLeave local sCtrlShift on dragDrop - _deleteBackgroundGraphic + _deleteBackgroundGraphic - if sFiles is empty then pass dragDrop + if the controlKey is not "down" and sFiles is empty then pass dragDrop - _setDefaultStack + _setDefaultStack - if _ItIsIDEStack(sMouseStack) is true then - put the short name of the topStack into sMouseStack - set the defaultstack to sMouseStack - end if + if _ItIsIDEStack(sMouseStack) is true then + put the short name of the topStack into sMouseStack + set the defaultstack to sMouseStack + end if - put the mouseLoc into sMouseLoc + put the mouseLoc into sMouseLoc - put the optionKey is down and the shiftKey is down and the number of lines of sFiles is 1 into sOptionShift - put the controlKey is down and the shiftKey is down into sCtrlShift + put the optionKey is down and the shiftKey is down and the number of lines of sFiles is 1 into sOptionShift + put the controlKey is down and the shiftKey is down into sCtrlShift - if sFiles is not empty then - lock screen; lock messages;lock cursor + if sFiles is not empty then + lock screen; lock messages;lock cursor - set the cursor to watch + set the cursor to watch - repeat for each line tFile in sFiles - _importFile tFile - end repeat + repeat for each line tFile in sFiles + _importFile tFile + end repeat - unlock messages + unlock messages - choose pointer tool + choose pointer tool - if there is a sLastControl then - focus on nothing - select empty - select sLastControl - end if + if there is a sLastControl then + focus on nothing + select empty + select sLastControl + end if - unlock screen; unlock messages; unlock cursor - exit dragDrop - end if + unlock screen; unlock messages; unlock cursor + exit dragDrop + end if - pass dragDrop + pass dragDrop end dragDrop # remove data being dragged. on dragEnd - _deleteBackgroundGraphic - pass dragEnd + _deleteBackgroundGraphic + pass dragEnd end dragEnd # remove data being dragged. on suspendStack - if sFiles is not empty then - _deleteBackgroundGraphic - delete variable sMouseStack - end if - pass suspendStack + if sFiles is not empty then + _deleteBackgroundGraphic + delete variable sMouseStack + end if + pass suspendStack end suspendStack private command _acceptDrop - put the dragData["files"] into sFiles + put the dragData["files"] into sFiles + + _setDefaultStack - _setDefaultStack - if _inMouseStack() and _filesTypeDragDrop(sFiles) is true and the cantModify of stack sMouseStack is not true then - set the dragAction to "copy" - else - set the dragAction to "none" - _deleteBackgroundGraphic - unlock messages - exit _acceptDrop - end if + if the controlKey is "down" and _inMouseStack() and _filesTypeDragDrop(sFiles) is true and the cantModify of stack sMouseStack is not true then + set the dragAction to "copy" + else + set the dragAction to "none" + _deleteBackgroundGraphic + unlock messages + exit _acceptDrop + end if - if there is not graphic "frlDragDropBack" of this cd of stack sMouseStack then - lock messages - # I create this graph because the drag & drop message is not generated on the card - create invisible graphic "frlDragDropBack" in this cd - put it into sLongIdBackGraphic + if there is not graphic "frlDragDropBack" of this cd of stack sMouseStack then + lock messages - set the rect of sLongIdBackGraphic to the rect of this cd of stack sMouseStack + # I create this graph because the drag & drop message is not generated on the card + create invisible graphic "frlDragDropBack" in this cd + put it into sLongIdBackGraphic - try - set the opaque of sLongIdBackGraphic to true - set the blendlevel of sLongIdBackGraphic to 100 - set the layer of sLongIdBackGraphic to bottom - set the lineSize of sLongIdBackGraphic to 0 - set the backColor of sLongIdBackGraphic to revIDEColor("edition_color") - set the visible of sLongIdBackGraphic to true - end try + set the rect of sLongIdBackGraphic to the rect of this cd of stack sMouseStack - put empty into sDragDestination - put empty into sTypeDragDestination - put empty into sOptionShift + try + set the opaque of sLongIdBackGraphic to true + set the blendlevel of sLongIdBackGraphic to 100 + set the layer of sLongIdBackGraphic to bottom + set the lineSize of sLongIdBackGraphic to 0 + set the backColor of sLongIdBackGraphic to revIDEColor("edition_color") + set the visible of sLongIdBackGraphic to true + end try - if _ItIsIDEStack(sMouseStack) is true - then set the blendlevel of sLongIdBackGraphic to 100 - else set the blendlevel of sLongIdBackGraphic to 0 - unlock messages - end if + put empty into sDragDestination + put empty into sTypeDragDestination + put empty into sOptionShift + + if _ItIsIDEStack(sMouseStack) is true + then set the blendlevel of sLongIdBackGraphic to 100 + else set the blendlevel of sLongIdBackGraphic to 0 + unlock messages + end if end _acceptDrop private command _importFile pFilePath - local tExtension + local tExtension + + if the controlKey is not "down" + then exit _importFile - set the itemdel to "." + set the itemdel to "." - lock messages + lock messages - put _dragDestination() into sDragDestination + put _dragDestination() into sDragDestination - _deleteBackgroundGraphic + _deleteBackgroundGraphic - put word 1 of sDragDestination into sTypeDragDestination - put item - 1 of pFilePath into tExtension + put word 1 of sDragDestination into sTypeDragDestination + put item - 1 of pFilePath into tExtension - set the itemdel to comma + set the itemdel to comma - if there is a file pFilePath then - switch + if there is a file pFilePath then + switch # SVG - case tExtension is "svg" - _importPathSVG pFilePath - break - - # LiveCode, Revolution and MetaCard binary stack files - case tExtension is among the items of kBynaryStack - unlock messages - go to card 1 of stack pFilePath - break - - # Script-only stack - case tExtension is kScriptOnlyStack - edit the script of stack pFilePath - break - - # Images file - case tExtension is among the items of kImage - _importImage pFilePath, "file" - break - - # Audio and Videos file - case tExtension is among the items of kAudio - _importPlayer pFilePath - break - - # Text Plan - case tExtension is among the items of kTextPlan - _importTextPlan pFilePath - break - - # LiveCode Extension - case tExtension is kLiveCodeExtension - _installExtension pFilePath - break - - end switch - - end if - unlock messages + case tExtension is "svg" + _importPathSVG pFilePath + break + + # LiveCode, Revolution and MetaCard binary stack files + case tExtension is among the items of kBynaryStack + unlock messages + go to card 1 of stack pFilePath + break + + # Script-only stack + case tExtension is kScriptOnlyStack + edit the script of stack pFilePath + break + + # Images file + case tExtension is among the items of kImage + _importImage pFilePath, "file" + break + + # Audio and Videos file + case tExtension is among the items of kAudio + _importPlayer pFilePath + break + + # Text Plan + case tExtension is among the items of kTextPlan + _importTextPlan pFilePath + break + + # LiveCode Extension + case tExtension is kLiveCodeExtension + _installExtension pFilePath + break + + end switch + + end if + unlock messages end _importFile private command _importImage pPathOrData, pType - local tNameFile, tImageData, tNewImage + local tNameFile, tImageData, tNewImage - set the itemdel to slash + set the itemdel to slash - _setDefaultStack + _setDefaultStack - if _ItIsIDEStack(sMouseStack) is true then - put the short name of the topStack into sMouseStack - set the defaultstack to sMouseStack - end if + if _ItIsIDEStack(sMouseStack) is true then + put the short name of the topStack into sMouseStack + set the defaultstack to sMouseStack + end if - if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then + if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then - if pType is "file" then + if pType is "file" then - if there is a sDragDestination and sTypeDragDestination is "image" and sOptionShift is true then - local tLockLoc + if there is a sDragDestination and sTypeDragDestination is "image" and sOptionShift is true then + local tLockLoc - put the lockLoc of sDragDestination into tLockLoc - set the lockLoc of sDragDestination to true + put the lockLoc of sDragDestination into tLockLoc + set the lockLoc of sDragDestination to true - if the filename of sDragDestination is empty then - set the text of sDragDestination to URL ("binfile:" & pPathOrData) - else - set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) - end if + if the filename of sDragDestination is empty then + set the text of sDragDestination to URL ("binfile:" & pPathOrData) + else + set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) + end if - set the lockLoc of sDragDestination to tLockLoc + set the lockLoc of sDragDestination to tLockLoc - put sDragDestination into sLastControl + put sDragDestination into sLastControl - exit _importImage - end if + exit _importImage + end if - if sCtrlShift is false then set the text of templateImage to URL ("binfile:" & pPathOrData) + if sCtrlShift is false then set the text of templateImage to URL ("binfile:" & pPathOrData) - put item - 1 of pPathOrData into tNameFile + put item - 1 of pPathOrData into tNameFile - create image tNameFile in this cd - put it into tNewImage + create image tNameFile in this cd + put it into tNewImage - if the text of tNewImage is empty then - set the filename of tNewImage to _convertPathToRelativePath(pPathOrData) - end if + if the text of tNewImage is empty then + set the filename of tNewImage to _convertPathToRelativePath(pPathOrData) + end if - if there is tNewImage then + if there is tNewImage then - _scaleImage tNewImage + _scaleImage tNewImage - if sMouseLoc is within the rect of card 1 of stack sMouseStack then - set the loc of tNewImage to sMouseLoc - else - set the loc of tNewImage to (the loc of cd 1 of stack sMouseStack) - end if + if sMouseLoc is within the rect of card 1 of stack sMouseStack then + set the loc of tNewImage to sMouseLoc + else + set the loc of tNewImage to (the loc of cd 1 of stack sMouseStack) + end if - put tNewImage into sLastControl - end if + put tNewImage into sLastControl + end if - reset templateImage + reset templateImage - else - local tOldText, tNewText - put drawingSvgCompileFile(pPathOrData) into tNewText + else + local tOldText, tNewText + put drawingSvgCompileFile(pPathOrData) into tNewText - if tNewText is not empty then + if tNewText is not empty then - if there is a sDragDestination and sTypeDragDestination is "image" then - put the text of sDragDestination into tOldText + if there is a sDragDestination and sTypeDragDestination is "image" then + put the text of sDragDestination into tOldText - set the text of sDragDestination to tNewText + set the text of sDragDestination to tNewText - if the text of sDragDestination is empty then - set the text of sDragDestination to tOldText - end if + if the text of sDragDestination is empty then + set the text of sDragDestination to tOldText + end if - else - put the mouseLoc into sMouseLoc - set the text of templateImage to tNewText + else + put the mouseLoc into sMouseLoc + set the text of templateImage to tNewText - put item - 1 of pPathOrData into tNameFile - create image tNameFile in this cd - put it into tNewImage + put item - 1 of pPathOrData into tNameFile + create image tNameFile in this cd + put it into tNewImage - if there is tNewImage then - _scaleImage tNewImage + if there is tNewImage then + _scaleImage tNewImage - if sMouseLoc is within the rect of card 1 of stack sMouseStack then - set the loc of tNewImage to sMouseLoc + if sMouseLoc is within the rect of card 1 of stack sMouseStack then + set the loc of tNewImage to sMouseLoc - else - set the loc of tNewImage to (the loc of cd 1 of stack sMouseStack) + else + set the loc of tNewImage to (the loc of cd 1 of stack sMouseStack) - end if + end if - put tNewImage into sLastControl - end if + put tNewImage into sLastControl + end if - reset templateImage - end if - else - beep - end if - end if - end if + reset templateImage + end if + else + beep + end if + end if + end if end _importImage private command _importPlayer pPathOrData - local tNameFile, tNumPlayer - set the itemdel to slash + local tNameFile, tNumPlayer + set the itemdel to slash - _setDefaultStack + _setDefaultStack - if _ItIsIDEStack(sMouseStack) is true then - put the short name of the topStack into sMouseStack - set the defaultstack to sMouseStack - end if + if _ItIsIDEStack(sMouseStack) is true then + put the short name of the topStack into sMouseStack + set the defaultstack to sMouseStack + end if - if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then + if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then - if there is a sDragDestination and sTypeDragDestination is "player" and sOptionShift is true then + if there is a sDragDestination and sTypeDragDestination is "player" and sOptionShift is true then - set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) - put sDragDestination into sLastControl - else - local tNewPlayer + set the filename of sDragDestination to _convertPathToRelativePath(pPathOrData) + put sDragDestination into sLastControl + else + local tNewPlayer - set the filename of templatePlayer to _convertPathToRelativePath(pPathOrData) - set the showController of templatePlayer to true + set the filename of templatePlayer to _convertPathToRelativePath(pPathOrData) + set the showController of templatePlayer to true - put item - 1 of pPathOrData into tNameFile - create player tNameFile in this cd - put it into tNewPlayer + put item - 1 of pPathOrData into tNameFile + create player tNameFile in this cd + put it into tNewPlayer - if sMouseLoc is within the rect of card 1 of stack sMouseStack then - set the loc of tNewPlayer to sMouseLoc - else - set the loc of tNewPlayer to (the loc of cd 1 of stack sMouseStack) - end if + if sMouseLoc is within the rect of card 1 of stack sMouseStack then + set the loc of tNewPlayer to sMouseLoc + else + set the loc of tNewPlayer to (the loc of cd 1 of stack sMouseStack) + end if - put tNewPlayer into sLastControl - end if + put tNewPlayer into sLastControl + end if - reset templatePlayer - end if + reset templatePlayer + end if end _importPlayer private command _importPathSVG pFilePath - local tNewWidget, tPathSVG + local tNewWidget, tPathSVG - set the itemdel to slash + set the itemdel to slash - _setDefaultStack + _setDefaultStack - if _ItIsIDEStack(sMouseStack) is true then - put the short name of the topStack into sMouseStack - set the defaultstack to sMouseStack - end if + if _ItIsIDEStack(sMouseStack) is true then + put the short name of the topStack into sMouseStack + set the defaultstack to sMouseStack + end if - put _getPathSVG(pFilePath) into tPathSVG + put _getPathSVG(pFilePath) into tPathSVG - if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then - if tPathSVG is not empty then + if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then + if tPathSVG is not empty then - local tKind - try - put the kind of sDragDestination into tKind - end try + local tKind + try + put the kind of sDragDestination into tKind + end try - if there is a sDragDestination and sTypeDragDestination is "widget" and tKind is "com.livecode.widget.svgpath" and sOptionShift is true then + if there is a sDragDestination and sTypeDragDestination is "widget" and tKind is "com.livecode.widget.svgpath" and sOptionShift is true then - set the iconPath of sDragDestination to tPathSVG + set the iconPath of sDragDestination to tPathSVG - put sDragDestination into sLastControl - else + put sDragDestination into sLastControl + else - create widget as "com.livecode.widget.svgpath" in this cd - put it into tNewWidget + create widget as "com.livecode.widget.svgpath" in this cd + put it into tNewWidget - set the iconPath of tNewWidget to tPathSVG - set the width of tNewWidget to 180 - set the height of tNewWidget to 180 + set the iconPath of tNewWidget to tPathSVG + set the width of tNewWidget to 180 + set the height of tNewWidget to 180 - if sMouseLoc is within the rect of card 1 of stack sMouseStack then - set the loc of tNewWidget to sMouseLoc - else - set the loc of tNewWidget to (the loc of cd 1 of stack sMouseStack) - end if + if sMouseLoc is within the rect of card 1 of stack sMouseStack then + set the loc of tNewWidget to sMouseLoc + else + set the loc of tNewWidget to (the loc of cd 1 of stack sMouseStack) + end if - put tNewWidget into sLastControl - end if - else - _importImage pFilePath, "SVG_Data" - end if - end if + put tNewWidget into sLastControl + end if + else + _importImage pFilePath, "SVG_Data" + end if + end if end _importPathSVG private command _importTextPlan pFilePath - local tText + local tText - _setDefaultStack + _setDefaultStack - if _ItIsIDEStack(sMouseStack) is true then - put the short name of the topStack into sMouseStack - set the defaultstack to sMouseStack - end if + if _ItIsIDEStack(sMouseStack) is true then + put the short name of the topStack into sMouseStack + set the defaultstack to sMouseStack + end if - if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then - put URL("file:" & pFilePath) into tText + if there is a stack sMouseStack and not _ItIsIDEStack(sMouseStack) then + put URL("file:" & pFilePath) into tText - if there is a sDragDestination and sTypeDragDestination is "field" and sOptionShift is true then - set the text of sDragDestination to tText + if there is a sDragDestination and sTypeDragDestination is "field" and sOptionShift is true then + set the text of sDragDestination to tText - else - create field - put it into sLastControl - set the text of sLastControl to tText - set the locktext of sLastControl to true + else + create field + put it into sLastControl + set the text of sLastControl to tText + set the locktext of sLastControl to true - if sMouseLoc is within the rect of card 1 of stack sMouseStack then - set the loc of sLastControl to sMouseLoc - else - set the loc of sLastControl to (the loc of cd 1 of stack sMouseStack) - end if - end if - end if + if sMouseLoc is within the rect of card 1 of stack sMouseStack then + set the loc of sLastControl to sMouseLoc + else + set the loc of sLastControl to (the loc of cd 1 of stack sMouseStack) + end if + end if + end if end _importTextPlan private command _installExtension pExtensionURL - // get from local .lce file - send"installExtension pExtensionURL, , widget" to stack"revIDEExtensionManager" in 0.1 sec + // get from local .lce file + send"installExtension pExtensionURL, , widget" to stack"revIDEExtensionManager" in 0.1 sec end _installExtension private command _setDefaultStack - if there is a the mouseStack then put the short name of the mouseStack into sMouseStack + if there is a the mouseStack then put the short name of the mouseStack into sMouseStack - if sOldMouseStack is not sMouseStack then - _deleteBackgroundGraphic - end if + if sOldMouseStack is not sMouseStack then + _deleteBackgroundGraphic + end if - put sMouseStack into sOldMouseStack - set the defaultStack to sMouseStack + put sMouseStack into sOldMouseStack + set the defaultStack to sMouseStack end _setDefaultStack private function _dragDestination - local tStack, tDragDestination + local tStack, tDragDestination - _setDefaultStack + _setDefaultStack - put the dragDestination into tDragDestination + put the dragDestination into tDragDestination - if there is an stack sMouseStack then + if there is an stack sMouseStack then - if there is tDragDestination then - put the long id of tDragDestination into tDragDestination + if there is tDragDestination then + put the long id of tDragDestination into tDragDestination - put ideStackOfObject(tDragDestination) into tStack + put ideStackOfObject(tDragDestination) into tStack - if there is a tDragDestination and tStack is the long name stack sMouseStack then - return tDragDestination - end if + if there is a tDragDestination and tStack is the long name stack sMouseStack then + return tDragDestination + end if - end if + end if - return the long id of this cd - end if + return the long id of this cd + end if end _dragDestination private command _deleteBackgroundGraphic - if sLongIdBackGraphic is not empty and there is sLongIdBackGraphic then - delete sLongIdBackGraphic - delete variable sLongIdBackGraphic - end if + if sLongIdBackGraphic is not empty and there is sLongIdBackGraphic then + delete sLongIdBackGraphic + delete variable sLongIdBackGraphic + end if end _deleteBackgroundGraphic private function _convertPathToRelativePath pPath - local tStackPath + local tStackPath - set the itemdel to slash + set the itemdel to slash - if there is not a stack sMouseStack then return pPath + if there is not a stack sMouseStack then return pPath - put item 1 to - 2 of the effective filename of stack sMouseStack into tStackPath - if there is not a folder tStackPath then return pPath + put item 1 to - 2 of the effective filename of stack sMouseStack into tStackPath + if there is not a folder tStackPath then return pPath - replace backslash with slash in pPath - replace tStackPath & slash with empty in pPath + replace backslash with slash in pPath + replace tStackPath & slash with empty in pPath - return pPath + return pPath end _convertPathToRelativePath private function _getPathSVG pFilePath - local tSVG, tPathOpen , tOpen = 0, tClose, tSVGPath, tNumChars, tNewPath - set the itemdel to quote + local tSVG, tPathOpen , tOpen = 0, tClose, tSVGPath, tNumChars, tNewPath + set the itemdel to quote - if there is a file pFilePath then + if there is a file pFilePath then - put URL("file:" & pFilePath ) into tSVG + put URL("file:" & pFilePath ) into tSVG - put length(tSVG) into tNumChars + put length(tSVG) into tNumChars - if "path" is in tSVG then - repeat for tNumChars - put offset("path", tSVG, tPathOpen) into tOpen + if "path" is in tSVG then + repeat for tNumChars + put offset("path", tSVG, tPathOpen) into tOpen - if tOpen is 0 then exit repeat - if tNumChars <= tOpen then exit repeat - put tOpen + tPathOpen into tPathOpen + if tOpen is 0 then exit repeat + if tNumChars <= tOpen then exit repeat + put tOpen + tPathOpen into tPathOpen - if the char(tPathOpen - 1) of tSVG is not "<" and char (tPathOpen - 1) of tSVG is not space then - put tPathOpen + 3 into tPathOpen - next repeat - end if + if the char(tPathOpen - 1) of tSVG is not "<" and char (tPathOpen - 1) of tSVG is not space then + put tPathOpen + 3 into tPathOpen + next repeat + end if - put offset("d=" & quote, tSVG, tPathOpen) into tOpen - if tOpen is 0 then exit repeat - put tOpen + tPathOpen + 3 into tOpen + put offset("d=" & quote, tSVG, tPathOpen) into tOpen + if tOpen is 0 then exit repeat + put tOpen + tPathOpen + 3 into tOpen - put offset(quote, tSVG, tOpen) into tClose - if tClose is 0 then exit repeat - put tOpen + tClose into tClose + put offset(quote, tSVG, tOpen) into tClose + if tClose is 0 then exit repeat + put tOpen + tClose into tClose - put char tOpen to (tClose - 1) of tSVG into tNewPath - add 1 to tClose - put tClose into tPathOpen + put char tOpen to (tClose - 1) of tSVG into tNewPath + add 1 to tClose + put tClose into tPathOpen - get (the item 1 to 2 of ( the char tClose to - 1 of tSVG)) + get (the item 1 to 2 of ( the char tClose to - 1 of tSVG)) - if the trueWord 1 of it is "fill" and the trueWord -1 of it is "none" then - next repeat - end if + if the trueWord 1 of it is "fill" and the trueWord -1 of it is "none" then + next repeat + end if - put tNewPath && cr after tSVGPath + put tNewPath && cr after tSVGPath - end repeat - end if - else + end repeat + end if + else - put tSVG into tSVGPath - end if + put tSVG into tSVGPath + end if - local tWidget, tOutPathSVG + local tWidget, tOutPathSVG - create widget as "com.livecode.widget.svgpath" - put it into tWidget + create widget as "com.livecode.widget.svgpath" + put it into tWidget - try - set the iconPath of tWidget to tSVGPath - put tSVGPath into tOutPathSVG - end try + try + set the iconPath of tWidget to tSVGPath + put tSVGPath into tOutPathSVG + end try - delete tWidget + delete tWidget - return tOutPathSVG + return tOutPathSVG end _getPathSVG private function _filesTypeDragDrop pFiles - local tResult = true, tExtension + local tResult = true, tExtension - if pFiles is empty then return false + if pFiles is empty then return false - repeat for each line tFile in pFiles + repeat for each line tFile in pFiles - set the itemdel to "." - put item - 1 of tFile into tExtension + set the itemdel to "." + put item - 1 of tFile into tExtension - set the itemdel to comma + set the itemdel to comma - if tExtension is not among the items of (kBynaryStack,kScriptOnlyStack,kAudio,kImage,kTextPlan,kLiveCodeExtension) then - put false into tResult - exit repeat - end if - end repeat + if tExtension is not among the items of (kBynaryStack,kScriptOnlyStack,kAudio,kImage,kTextPlan,kLiveCodeExtension) then + put false into tResult + exit repeat + end if + end repeat - return tResult + return tResult end _filesTypeDragDrop private command _scaleImage pLongId - local tFormattedWidth, tFormattedHeight, tWidthCard, tHeightCard, tAspectRatio + local tFormattedWidth, tFormattedHeight, tWidthCard, tHeightCard, tAspectRatio - _setDefaultStack + _setDefaultStack - if _ItIsIDEStack(sMouseStack) is true then - put the short name of the topStack into sMouseStack - set the defaultstack to sMouseStack - end if + if _ItIsIDEStack(sMouseStack) is true then + put the short name of the topStack into sMouseStack + set the defaultstack to sMouseStack + end if - put the formattedWidth of pLongId into tFormattedWidth - put the formattedHeight of pLongId into tFormattedHeight + put the formattedWidth of pLongId into tFormattedWidth + put the formattedHeight of pLongId into tFormattedHeight - put the width of this card into tWidthCard - put the height of this card into tHeightCard + put the width of this card into tWidthCard + put the height of this card into tHeightCard - if tFormattedWidth is 0 or tFormattedHeight is 0 or (tFormattedWidth < tWidthCard and tFormattedHeight < tHeightCard) then - exit _scaleImage - end if + if tFormattedWidth is 0 or tFormattedHeight is 0 or (tFormattedWidth < tWidthCard and tFormattedHeight < tHeightCard) then + exit _scaleImage + end if - put min(tWidthCard/tFormattedWidth, tHeightCard/tFormattedHeight) into tAspectRatio + put min(tWidthCard/tFormattedWidth, tHeightCard/tFormattedHeight) into tAspectRatio - set the width of pLongId to tFormattedWidth * tAspectRatio - set the height of pLongId to tFormattedHeight * tAspectRatio + set the width of pLongId to tFormattedWidth * tAspectRatio + set the height of pLongId to tFormattedHeight * tAspectRatio end _scaleImage private function _ItIsIDEStack pNameStack - if there is not a stack pNameStack then return false - return the mainstack of stack pNameStack is not among the lines of ideUserMainStacks() + if there is not a stack pNameStack then return false + return the mainstack of stack pNameStack is not among the lines of ideUserMainStacks() end _ItIsIDEStack private command _cancelPendingMessages pMessageName - local tPendingMessages + local tPendingMessages - set the itemDelimiter to comma - put the pendingMessages into tPendingMessages + set the itemDelimiter to comma + put the pendingMessages into tPendingMessages - repeat for each line tMessage in tPendingMessages - if item 3 of tMessage is pMessageName then - cancel item 1 of tMessage - end if - end repeat + repeat for each line tMessage in tPendingMessages + if item 3 of tMessage is pMessageName then + cancel item 1 of tMessage + end if + end repeat end _cancelPendingMessages private function _inMouseStack - local tTarget, tStackOfControlLeave + local tTarget, tStackOfControlLeave - put the target into tTarget + put the target into tTarget - if tTarget is empty then return false + if tTarget is empty then return false - if word 1 of tTarget is in "card stack" then - put ideStackOfObject( the long id of tTarget) into tStackOfControlLeave + if word 1 of tTarget is in "card stack" then + put ideStackOfObject( the long id of tTarget) into tStackOfControlLeave - if there is a stack tStackOfControlLeave and globalLoc(the mouseLoc) is not within the rect of stack tStackOfControlLeave then - _deleteBackgroundGraphic - return false - end if - end if + if there is a stack tStackOfControlLeave and globalLoc(the mouseLoc) is not within the rect of stack tStackOfControlLeave then + _deleteBackgroundGraphic + return false + end if + end if - return true + return true end _inMouseStack