Monday, December 11, 2017

#1 2015-10-19 05:21:02 pm

Titanium
Member
From:: ~/Desktop
Registered: 2005-08-22
Posts: 43
Website

Images in Media Library

Hello,

3 images into the project: green.png, orange.png, and red.png (bullets).

In applicationWillFinishLaunching:

Applescript:

set greenBulletPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("green", "png") as string)
set greenBullet to NSImage's alloc()'s initWithContentsOfFile_(greenBulletPath)

set orangeBulletPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("orange", "png") as string)
set orangeBullet to NSImage's alloc()'s initWithContentsOfFile_(orangeBulletPath)

set redBulletPath to (current application's NSBundle's mainBundle()'s pathForResource_ofType_("red", "png") as string)
set redBullet to NSImage's alloc()'s initWithContentsOfFile_(redBulletPath)

For display the red image, for example:

Applescript:

myImageView's setImage_(redBullet)

I see there are already similar images in the Media Library named: NSStatusAvailable, NSStatusPartiallyAvailable, and NSStatusUnavailable but I don't know how use them... Is it possible? hmm

Thanks!


iMac 27" 3,4 Ghz - macOS High Sierra
https://www.titanium-software.fr

Offline

 

#2 2015-10-20 12:36:13 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5197

Re: Images in Media Library

For your first examples, all you need is:

Applescript:

set anImage to current application's NSImage's imageNamed:"green"

As long as it's in Resources, it will be found.

But what you're after is:

Applescript:

set anImage to current application's NSImage's imageNamed:"NSStatusAvailable"


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2015-10-20 02:08:11 am

Titanium
Member
From:: ~/Desktop
Registered: 2005-08-22
Posts: 43
Website

Re: Images in Media Library

Applescript:

set anImage to current application's NSImage's imageNamed:"green"

Thanks a lot Shane!! It works...

Strange behavior. When I deleted the green, red, and orange images, the NSStatusAvailable, NSStatusPartiallyAvailable, and NSStatusUnavailable are also deleted in the Media Library. Probably the same objects. hmm
Then I reload the green, red, and orange images into the project and it's OK now.

cool


iMac 27" 3,4 Ghz - macOS High Sierra
https://www.titanium-software.fr

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)