Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit bd83b89

Browse files
authored
Merge pull request #1608 from livecode/pi-drag_drop_stackfiles
Pi drag drop stackfiles
2 parents 476fbb5 + 8c961a7 commit bd83b89

3 files changed

Lines changed: 67 additions & 13 deletions

File tree

Toolset/palettes/inspector/editors/com.livecode.pi.stackfiles.behavior.livecodescript

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,75 @@ on mouseUp
8080
revIDEAnswerFile "stack"
8181

8282
# Get the path of to the file
83-
local tStackFilePath
84-
put the result into tStackFilePath
83+
local tStackFilePaths
84+
put the result into tStackFilePaths
8585

86-
if tStackFilePath is not empty then
87-
local tEditorValue, tNewLine
88-
put the short name of stack tStackFilePath & comma & tStackFilePath into tNewLine
89-
put the editorValue of me into tEditorValue
90-
if tEditorValue is empty then
91-
put tNewLine into tEditorValue
92-
else
93-
put return & tNewLine after tEditorValue
94-
end if
95-
set the editorValue of me to tEditorValue
96-
updateProperty
86+
if tStackFilePaths is not empty AND tStackFilePaths is not "cancel" then
87+
addStacks tStackFilePaths
9788
end if
9889
break
9990
end switch
10091
end mouseUp
10192

93+
94+
on dragEnter
95+
if the short name of the target is "stackFilesField" then
96+
if the dragData["files"] is not empty then
97+
local tExtensions, tFile
98+
99+
set the wholematches to true
100+
put revIDEAcceptedTypes("stack") into tExtensions
101+
repeat for each line tFile in the dragData["files"]
102+
if fileExtension(tFile) is among the items of tExtensions then
103+
set the dragAction to "copy"
104+
exit repeat
105+
end if
106+
end repeat
107+
end if
108+
else
109+
pass dragEnter
110+
end if
111+
end dragEnter
112+
113+
114+
on dragDrop
115+
if the short name of the target is "stackFilesField" then
116+
addStacks the dragData["files"]
117+
else
118+
pass dragDrop
119+
end if
120+
end dragDrop
121+
122+
123+
private command addStacks pStackFilePaths
124+
local tEditorValue, tNewLine
125+
126+
put the editorValue of me into tEditorValue
127+
128+
repeat for each line tStackFilePath in pStackFilePaths
129+
put the short name of stack tStackFilePath & comma & tStackFilePath into tNewLine
130+
if tEditorValue is empty then
131+
put tNewLine into tEditorValue
132+
else
133+
put return & tNewLine after tEditorValue
134+
end if
135+
end repeat
136+
set the editorValue of me to tEditorValue
137+
updateProperty
138+
end addStacks
139+
140+
private function fileExtension pFilename
141+
set the itemDelimiter to "/"
142+
put the last item of pFilename into pFilename
143+
set the itemDelimiter to "."
144+
if the number of items of pFilename > 1 then
145+
return the last item of pFilename
146+
else
147+
return empty
148+
end if
149+
end fileExtension
150+
151+
102152
on valueChanged
103153
local tValue
104154
put field "stackFilesField" into tValue

notes/bugfix-18878.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Setting stackFiles in PI causes an error if you "cancel" the file dialog or select multiple files

notes/bugfix-5787.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Drag and drop stackfiles
2+
3+
You can now drag and drop stack files onto the stackFiles field in the PI.

0 commit comments

Comments
 (0)