Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSScriptCommand with record parameter



After a few hours googling on the internet on the topic of NSDictionary and AppleScript record, I have come to the conclusion that I also need to define a record-type in my sdef:

<record-type name="scriptmenurecord" code="scMe">
<property name="name" code="scNa" type="text" description="the name of the frontmost application">
<cocoa key="frontmostname"/>
</property>
<property name="menu" code="scMi" type="integer" description="The menu item number of the selected menu, starting from 0">
<cocoa key="menunumber"/>
</property>
</record-type>

and then use this instead of record in the command "selected scriptmenu"

But the result is exactly the same. And the curious thing is that I am unable to see the above record-type when I open my apps Dictionary in Script Editor.

Ivan


Den 23. nov.. 2007 kl. 08:13 skrev Ivan C Myrvold:

I want to know which application is frontmost when I select a script in the script menu, so I put this into the sdef file of my application:

<command name="selected scriptmenu" code="TaCldosc" description="A Script menu item have been selected">
<cocoa class="SelectedScriptMenu"/>
<direct-parameter>
<type type="record" list="no"/>
</direct-parameter>
</command>

The script that I put in the script menu looks like this:

property frontmostApplication : "none"

tell application "System Events"
set frontmostApplication to item 1 of (get name of processes whose frontmost is true)
end tell

tell application "Tansa"
activate
selected scriptmenu {name:frontmostApplication, menu:5}
end tell

The result is printed out with a NSLog:

2007-11-23 07:33:32.822 Tansa[8848:10b] SelectedScriptMenu dict: {
    1886282093 = Mail;
    1668116085 = 5;
}

I thought the key should be the same as what I put in the script, "name" and "menu", but they came out as integers. Why?
How can I get the dict to be that?

Ivan
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-implementors mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-implementors/email@hidden

This email sent to email@hidden

References: 
 >NSScriptCommand with record parameter (From: Ivan C Myrvold <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.