On Aug 10, 2011, at 14:18, binaryghost wrote:
> I was interested in writing a script that would be called when and image is
> dropped on to the document and was wondering if there was a way to attach a
> script to such an event? Possibly a "documentReceivedImage" or something like
> that.
______________________________________________________________________
Hey There,
I'll be quite surprised if drag and drop is attachable, but you could select an
image in the Finder and run a script to insert whatever you want at the cursor
position.
------------------------------------------------------------------------------------------------
# Get the Finder selection. This will only get the first item.
tell application "Finder"
set sel to selection as alias list
if sel ≠ {} then
set fSel to first item of sel
end if
end tell
# More info available.
set fileInfo to info for fSel
# Use Image Events to get image info.
tell application "Image Events"
set f to open fSel
tell f
set imgProperties to properties
set {imgX, imgY} to dimensions of (get properties)
set imgName to name
end tell
end tell
set insertionText to "##SOME_TAGS## " & imgName & " ##SOME_TAGS##"
tell application "BBEdit"
tell text of front text window
set after selection to insertionText
end tell
end tell
------------------------------------------------------------------------------------------------
Or you could use a 'choose from' dialog instead of the Finder selection.
set theFileAlias to choose file
set thePosixFilePath to (POSIX path of theFileAlias) as text
tell application "BBEdit" to tell front text window
set text of selection to thePosixFilePath
end tell
------------------------------------------------------------------------------------------------
Many things are possible. What are you trying to accomplish?
--
Best Regards,
Chris
--
You received this message because you are subscribed to the
"BBEdit Talk" discussion group on Google Groups.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
<http://groups.google.com/group/bbedit?hl=en>
If you have a feature request or would like to report a problem,
please email "[email protected]" rather than posting to the group.
Follow @bbedit on Twitter: <http://www.twitter.com/bbedit>