Can you add more than one control item to a scroll view - for example could you have an image view and a button in the same scroll view?
For example:
Here is my code to build a grid of images contained in a folder:
on clicked theObject
--set variables
set imageList to {}
set fileTypeList to {"Camera Raw", "TIFF", "EPSF", "JPEG", "GIF"}
--set shortcut definitions for our relevant objects
set photoMatrix to matrix "photoMatrix" of scroll view "scrollbars" of window "mainWin"
--pick a folder
set thisFolder to choose folder
--get the number of files in the folder
set folderList to list folder thisFolder without invisibles
--loop through the list and create a second array of good files
repeat with thisItem in folderList
set thisItemPath to (thisFolder as string) & thisItem
tell application "Finder"
set fileType to kind of (thisItemPath as alias)
if fileTypeList contains fileType then
copy thisItemPath to end of imageList
end if
end tell
end repeat
-- add rows to matrix
set imageCount to count of every item of imageList
set rowCount to round (imageCount / 5) rounding down
try
call method "renewRows:columns:" of photoMatrix with parameters {rowCount, 5}
call method "sizeToCells" of photoMatrix
update window "mainWin"
on error errMsg
display dialog "There was a problem with the creating the image grid:" & return & errMsg
end try
--import images
repeat with i from 1 to count of every item of imageList
set thisImage to item i of imageList as alias
tell photoMatrix
try
set image of cell i of photoMatrix to load image thisImage
on error errMsg
display dialog "There was a problem with loading the images into the image grid:" & return & errMsg
end try
end tell
end repeat
end clicked
this works fine, except I can’t get any mouse action or means to let the user click on the image to do something with it. So I created a button matrix and overlayed it on top of my image view matrix and placed them both in the same scroll view. However, when I do that I get an error message. Is there a way to do this where I can dynamically create a grid of images and have the user interact, even if it’s just a mouse click, with those images? Here’s the expanded code:
on clicked theObject
--set variables
set imageList to {}
set fileTypeList to {"Camera Raw", "TIFF", "EPSF", "JPEG", "GIF"}
--set shortcut definitions for our relevant objects
set photoMatrix to matrix "photoMatrix" of scroll view "scrollbars" of window "mainWin"
set buttonMatrix to matrix "buttonMatrix" of scroll view "scrollBars" of window "mainWin"
--pick a folder
set thisFolder to choose folder
--get the number of files in the folder
set folderList to list folder thisFolder without invisibles
--loop through the list and create a second array of good files
repeat with thisItem in folderList
set thisItemPath to (thisFolder as string) & thisItem
tell application "Finder"
set fileType to kind of (thisItemPath as alias)
if fileTypeList contains fileType then
copy thisItemPath to end of imageList
end if
end tell
end repeat
-- add rows to matrix
set imageCount to count of every item of imageList
set rowCount to round (imageCount / 5) rounding down
try
call method "renewRows:columns:" of photoMatrix with parameters {rowCount, 5}
call method "sizeToCells" of photoMatrix
call method "renewRows:columns:" of buttonMatrix with parameters {rowCount, 5}
call method "sizeToCells" of buttonMatrix
update window "mainWin"
on error errMsg
display dialog "fool!" & return
end try
--import images
repeat with i from 1 to count of every item of imageList
set thisImage to item i of imageList as alias
tell photoMatrix
try
set image of cell i of photoMatrix to load image thisImage
on error errMsg
end try
end tell
end repeat
end clicked