Re: [Newbie] What's wrong with my code ?
Re: [Newbie] What's wrong with my code ?
- Subject: Re: [Newbie] What's wrong with my code ?
- From: Eric Morand <email@hidden>
- Date: Tue, 27 Dec 2005 14:00:52 +0100
What exactly are you trying to do?
I'm trying to populate a popup button menu and set its selected menu
item. Here is the full code :
on awake from nib theObject
if (name of theObject) is "encodersPopup" then
set encodersPopup to theObject
delete every menu item of menu of encodersPopup
tell application "iTunes"
set availableEncoders to (format of every encoder)
set currentEncoder to (format of current encoder)
end tell
repeat with anEncoder in availableEncoders
set aMenuItem to (make new menu item at the end of menu items of
menu of encodersPopup with properties {title:anEncoder, enabled:true})
if (anEncoder as string) is (currentEncoder as string) then
set (current menu item of encodersPopup) to menu item aMenuItem
end if
end repeat
end if
end awake from nib
This is pretty simple :
- First, I get a list of all encoders available in iTunes
- Second, I get the current encoder of iTunes
- Third, I populate the popup button with the encoders available in
iTunes
- In the same time, I set the current item of the popup to the the
current encoder of iTunes
What seems strange to me is the syntax...
make new menu item at the end of menu items of menu of encodersPopup
with properties {title:anEncoder, enabled:true}
...works perfectly : it creates a menu item, add it the the end of
the popup menu items.
But, once I add "set aMenuItem to" and try to access the properties
of "aMenuItem", I have some error messages !
If I understand well, I can create a menu item but not reference it ?
Thanks for your help,
Eric.
Le 27 déc. 05 à 13:40, Mark J. Reed a écrit :
Raw AppleScript doesn't know how to make a new menu item. Menu
items are, in general, far too low-level a concept for AS, although
there may well be some osax (AppleScript extension) or scriptable
application which lets you do low-level GUI stuff from AS like that.
AS is not, in general, an application-development language; rather,
it's an application-automation language. It's best at letting you
"remote control" other application. You can certainly write
standalone apps in AppleScript, but you do so at a higher level
than what you're doing here, with commensurately less control over
find details like menus and their items.
What exactly are you trying to do?
On 12/27/05, Eric Morand <email@hidden> wrote:
Hi list !
After a lot of years spent with Objective-C, I'm back to
Applescript...and I've to confess that it is NOT that easy to
return !!!
In fact, I'm stuck with newbies problems (yes that's a shame). In
particular, here is a snipet of code that doesn't work :
set aMenuItem to (make new menu item)
set (title of aMenuItem) to "Test"
display dialog (title of aMenuItem)
Can anyone tell me what's wrong with this code ? I just can't see
where I made a mistake.
Thanks by advance,
Eric.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (Applescript-
email@hidden)
Help/Unsubscribe/Update your Subscription:
40mail.com
This email sent to email@hidden
--
Mark J. Reed < email@hidden>
Automator Ketchup : http://automatorketchup.blogspot.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden