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



Must be doing something wrong in defining the sdef. I made a copy of Sketch's record-type, and edited it to look like the one below.
When opening Sketch's dictionary, I can see in the first column, view, "Records". But this is missing in my applications dictionary.
Wonder why? There was no sdp error compiling the project, and I made sure I restarted Script Debugger and Script Editor.

Ivan


Den 23. nov.. 2007 kl. 12:21 skrev Christiaan Hofman:

Keys in AppleScript records are integers (4-char codes), not strings. For the record-type you have defined it is the "code" you have defined (like 'scNa'). I don't know *what* you actually log though. Note that in evaluatedArguments the cocoa keys are used instead of the 4-char codes.

The fact that the record types do not show up is a bug in Tiger. They do show up though in the longer listing in the lower pane (if you don't select anything in the second column of the browser). 

Christiaan

On 23 Nov 2007, at 11:47 AM, Ivan C Myrvold wrote:

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:

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>)
 >Re: NSScriptCommand with record parameter (From: Ivan C Myrvold <email@hidden>)
 >Re: NSScriptCommand with record parameter (From: Christiaan Hofman <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.