Apple Event in Cocoa

  • I am converting code done in Carbon to Coca, and it mostly goes well,
    but I am a bit confused about the difference in text.
    The AppleEvent looks like this in the old arbon code:

    { 1 } 'aevt':  TANS/trbm (i386){
              return id: 751960066 (0x2cd20002)
    ...
    ....
    ....
          key '----' -
            { 1 } 'list':  - 26 elements {
              { 1 } 'TEXT':  28 bytes {
                "bla bla bla bla"
              }
              { 1 } 'TEXT':  34 bytes {
                "bla bla bla bla"
              }
              { 1 } 'TEXT':  28 bytes {
                "bla bla bla bla"
    ....

    But when I send from Cocoa, it looks like this:

          key 'list' -
            { 1 } 'list':  - 26 elements {
              { 1 } 'utxt':  56 bytes {
                "............................"
              }
              { 1 } 'utxt':  68 bytes {
                ".................................."
              }
              { 1 } 'utxt':  56 bytes {

    I am using this code in Cocoa:
    NSAppleEventDescriptor *menulist = [NSAppleEventDescriptor
    listDescriptor];
    [menulist insertDescriptor:[NSAppleEventDescriptor
    descriptorWithString:@"bla bla bla"] atIndex:1];
    [menulist insertDescriptor:[NSAppleEventDescriptor
    descriptorWithString:@"bla bla bla"] atIndex:2];
    [menulist insertDescriptor:[NSAppleEventDescriptor
    descriptorWithString:@"bla bla bla"] atIndex:3];

    It looks like I get the strings as unicode in Cocoa. What can I do to
    get the same result as in the old Carbon code?

    Ivan
  • I'd say getting Unicode text sounds like a bonus to me ;) Why do you
    need MacRoman?

    On Oct 16, 2007, at 11:07 AM, Ivan C Myrvold wrote:

    > I am converting code done in Carbon to Coca, and it mostly goes
    > well, but I am a bit confused about the difference in text.
    > The AppleEvent looks like this in the old arbon code:
    >
    > { 1 } 'aevt':  TANS/trbm (i386){
    > return id: 751960066 (0x2cd20002)
    > ...
    > ....
    > ....
    > key '----' -
    > { 1 } 'list':  - 26 elements {
    > { 1 } 'TEXT':  28 bytes {
    > "bla bla bla bla"
    > }
    > { 1 } 'TEXT':  34 bytes {
    > "bla bla bla bla"
    > }
    > { 1 } 'TEXT':  28 bytes {
    > "bla bla bla bla"
    > ....
    >
    > But when I send from Cocoa, it looks like this:
    >
    > key 'list' -
    > { 1 } 'list':  - 26 elements {
    > { 1 } 'utxt':  56 bytes {
    > "............................"
    > }
    > { 1 } 'utxt':  68 bytes {
    > ".................................."
    > }
    > { 1 } 'utxt':  56 bytes {
    >
    > I am using this code in Cocoa:
    > NSAppleEventDescriptor *menulist = [NSAppleEventDescriptor
    > listDescriptor];
    > [menulist insertDescriptor:[NSAppleEventDescriptor
    > descriptorWithString:@"bla bla bla"] atIndex:1];
    > [menulist insertDescriptor:[NSAppleEventDescriptor
    > descriptorWithString:@"bla bla bla"] atIndex:2];
    > [menulist insertDescriptor:[NSAppleEventDescriptor
    > descriptorWithString:@"bla bla bla"] atIndex:3];
    >
    > It looks like I get the strings as unicode in Cocoa. What can I do
    > to get the same result as in the old Carbon code?
    >
    > Ivan
  • > I'd say getting Unicode text sounds like a bonus to me ;) Why do you
    > need MacRoman?

    Compatibility with the program to which he is sending the event. If it's
    looking for 'TEXT', 'utxt' won't work.

    The magic incantation is: coerceToDescriptorType:'TEXT'

    --
    Scott Ribe
    <scott_ribe...>
    http://www.killerbytes.com/
    (303) 722-0567 voice
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today