You are not logged in.
Hello,
With Xcode:
In a menu, I display an image with the iconForFile method.
Is it possible to reduce the size of this image?
Applescript:
# For example:
set itemMenu to current application's NSMenuItem's alloc()'s init()
set theImage to current application's NSWorkspace's sharedWorkspace()'s iconForFile:"/Applications"
itemMenu's setImage_(theImage)
itemMenu's setTitle_("Applications")
itemMenu's setAction_("menubarApplications:")
itemsMenuBar's addItem_(itemMenu)
...
Thanks!
iMac 27" 3,6 Ghz - MacBook Pro 14" M1 - MacOS Monterey
https://www.titanium-software.fr
Offline
The documentation for the NSWorkspace's 'iconForFile:' function, says the the returned NSImage is initially returned at 32 x 32 pixels, so as it's an NSImage, you could change it with one of the NSImage's function's, like this.
Applescript:
set theImage to current application's NSWorkspace's sharedWorkspace()'s iconForFile:"/Applications"
theImage's setSize:(current application's NSMakeSize(16, 16)) --16 x 16 pixels
Regards Mark
Last edited by Mark FX (2021-12-23 03:48:24 pm)
Offline
Great!!
Thanks a lot Mark!
iMac 27" 3,6 Ghz - MacBook Pro 14" M1 - MacOS Monterey
https://www.titanium-software.fr
Offline