• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How do I set a new image for a button?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How do I set a new image for a button?


  • Subject: How do I set a new image for a button?
  • From: Brian Christmas <email@hidden>
  • Date: Sun, 10 Aug 2014 18:24:40 +1000

G'day scripters

I've been through Shanes book, and looked at the Chapter 10 resources, but what I'm trying to do seems outside of those.

I've got four images that I'd like to set a buttons image to at various stages. I cannot work out what's wrong with my code.

Any advice please?

Regards

Santa

on setVolume_(sender)
tell application "iTunes" to set sound volume to my actualVolume as integer
  if my actualVolume as integer > 80 then
            set theImage to   pathForResource_ofType_("Speaker",".png")
            set theURL to fileURLWithPath_(theImage)
            set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
             else
if my actualVolume as integer > 40 then
                set theImage to   pathForResource_ofType_("Speaker medium",".png")
                set theURL to fileURLWithPath_(theImage)
                set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
                else
if my actualVolume as integer > 1 then
                    set theImage to   pathForResource_ofType_("Speaker low",".png")
                    set theURL to fileURLWithPath_(theImage)
                    set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
                    else
                    set theImage to   pathForResource_ofType_("Speaker off",".png")
                    set theURL to fileURLWithPath_(theImage)
                    set newImage to current application's NSImage's alloc()'s initWithContentsOfURL_theURL
iTunesPlayButton's setImage_(newImage)
end if
end if
end if
end setVolume_



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How do I set a new image for a button?
      • From: Shane Stanley <email@hidden>
  • Prev by Date: How do I get the selected title of a separate popup button
  • Next by Date: Re: How do I set a new image for a button?
  • Previous by thread: How do I get the selected title of a separate popup button
  • Next by thread: Re: How do I set a new image for a button?
  • Index(es):
    • Date
    • Thread