Get the folder's icon path
Hello,
I need to get the path of a folder's icon to do a thing, but I don't know where the icons are located.
Can anyone help me?
Thanks!
Hello,
I need to get the path of a folder's icon to do a thing, but I don't know where the icons are located.
Can anyone help me?
Thanks!
Hi,
Matteo_999 wrote:
Just a thing, the icon of the folder is pretty small, is there a way to make it bigger? T
Because the returned image has an initial size of 32 pixels by 32 pixels.
You can increase the size of the image with setSize, like this:
set myImage to current application's NSWorkspace's sharedWorkspace()'s iconForFile:posixPath -- get an image of 32 pixels by 32 pixels
myImage's setSize:{256, 256} -- resize the image to 256 pixels by 256 pixelsThanks, worked!
See you've been busty this morning, glad you got it all worked out.
I don;t do much Applescript Objective-C coding so I would be interested in seeing the code you came up with for accepting drags into the App window. If you get a chance I'd appreciate it it you could post it.
regards
Hi Frank, this is what i've done so far:
1) Create a new AppleScriptObjC file and name it as you want, mine is MSDropBox
2) Replace all the code with the following:
--
-- MSDropBox.applescript
-- Sync Folders
--
-- Created by Matteo La Mendola on 19/08/14.
-- Copyright (c) 2014 Matteo La Mendola. All rights reserved.
--
script MSDropBox
propertyparent : class"NSBox"
property theItem1 : missing value
property dropBox1 : missing value
property theURLs : missing value
on draggingEntered_(sender)
log "entered"
set pb to sender's draggingPasteboard()
set theOptions to {NSPasteboardURLReadingFileURLsOnlyKey:1}
return pb's canReadObjectForClasses_options_({current application's |NSURL|}, theOptions)
end draggingEntered_
on performDragOperation_(sender)
log "perform"
-- Get the file paths
set pb to sender's draggingPasteboard()
set theOptions to {NSPasteboardURLReadingFileURLsOnlyKey:1}
set theURLs to pb's readObjectsForClasses_options_({current application's |NSURL|}, theOptions)
log theURLs
set theURLs to theURLs's valueForKey:"path"
set theURLs to theURLs as list
current application's NSApp's delegate()'s wasDropped_sender_(theURLs, me)
returntrue
end performDragOperation_
endscript
3) Make a new outlet in the AppDelegate named dropBox1
4) Drag an NSBox into your XIB file and connect dropBox1 as outlet
5) Go to the AppDelegate.applescript file and insert this code in the applicationWillFinishLaunching handler:
on applicationWillFinishLaunching_(aNotification)
my dropBox1's registerForDraggedTypes_({"public.file-url"})
end applicationWillFinishLaunching_
6) In the AppDelegate insert this handler:
on wasDropped_sender_(itemDropped, sender)
log itemDropped
if sender's title() as text = "Box1" then
log "dropBox1"
else
log "dropBox2"
end if
end wasDropped_sender_
The if statement is only if you have more than one box
7) Select MSDropBox as custom class of the NSBox
And that's done!
This is how mine looks like:
Reply for any question 😉
Thanks I'll have look at it later
regards
Get the folder's icon path