I have two questions.
-
normally, when using text in a cell in a table view, if there is more text in the cell than can be displayed, the first portion of the text is displayed, followed by a “…” near the right end of the cell. I need to move this … to the left end of the cell. so instead of “some text belongs…” id get “…text belongs here” This is mainly needed as the cell in question will be containing paths to files, and in general, only the file name is terribly important, and the full path can e pushed off to the left.
-
My second question concerns images in image cells.
right now, a user can drag and drop an image file into an image cell and it gets displayed, and the file path is later used in my program to reference the file on a do shell script line. My users want the ability to drag images from web pages into the field. right now, they can drag the images there, and they will show up in the image cell, but I do not know how to find the url to get the file. Is it possible to do this? if not, how do I go about disabling the ability to drag the image, and only accept image files?
All help is much appreciated
Anyone have any suggestions for either of these?
as always jacques, you are my saviour. now, is there any easy way to turn the dragged image into an actual file, or is it easiest to just get the url and use curl or something to download the file?
Im sure there is a better way, but Ive got it working like this. my program also requires a jpg or png file, so it also converts the file to png if it isnt a supported type
if "Apple Web Archive pasteboard type" is in dataTypes then
set preferred type of pasteboard of dragInfo to "Apple Web Archive pasteboard type"
tell (get contents of pasteboard of dragInfo) to try
set the_Url to |WebResourceURL| of item 1 of |WebSubresources| of it -- a link reference, get the real URL of the image
on error
set the_Url to |WebResourceURL| of |WebMainResource| of it --get the Url of the image
end try
set previousDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to "/"
set imageFilename to last text item of the_Url
set AppleScript's text item delimiters to "."
set imageExtension to last text item of imageFilename
set AppleScript's text item delimiters to previousDelimiter
try
do shell script "curl " & the_Url & " --output /tmp/iTags-image-" & imageFilename
set tempImage to "/tmp/iTags-image-" & (random number (10000)) & imageFilename
if imageExtension is not in {"jpg", "png", "jpeg"} then
display dialog tempImage
tell application "Image Events"
set theImage to open file tempImage
set previousDelimiter to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set fileSplits to text items of tempImage
set last item of fileSplits to "png"
set newTempImage to fileSplits as string
set AppleScript's text item delimiters to previousDelimiter
save theImage as PNG in file newTempImage
close theImage
end tell
do shell script "rm " & tempImage
set tempImage to newTempImage
end if
end try
end if