Professional Web Applications Themes

NSPopupMenuButton not working - Mac Programming

Hi, I'm integrating Cocoa UI in a Carbon app. I'm creating UI elements on the fly. I'm struggling with NSPopupMenuButton. The popup button displays properly, so does the popup, but the chosen item in the popup doesn't get selected, and I don't receive any action from the popup. Here is my code: // subclassing NSPopup interface XCocoaDropDown : NSPopUpButton { } - (IBAction)controlActioned:(id)sender; // creating the popup NSRect rect = { { 100, 100 }, { 200, 24 } }; XCocoaDropDown* dropdown = [[XCocoaDropDown alloc] initWithFrame:rect]; [dropdown setTarget: dropdown ]; [dropdown setAction:selector(controlActioned:)]; // filling the popup long i; for(i=0;i<3;i++) { ...

  1. #1

    Default NSPopupMenuButton not working

    Hi,

    I'm integrating Cocoa UI in a Carbon app.

    I'm creating UI elements on the fly. I'm struggling with NSPopupMenuButton.
    The popup button displays properly, so does the popup, but the chosen item
    in the popup doesn't get selected, and I don't receive any action from the
    popup. Here is my code:

    // subclassing NSPopup

    interface XCocoaDropDown : NSPopUpButton {
    }
    - (IBAction)controlActioned:(id)sender;


    // creating the popup

    NSRect rect = { { 100, 100 }, { 200, 24 } };
    XCocoaDropDown* dropdown = [[XCocoaDropDown alloc] initWithFrame:rect];
    [dropdown setTarget: dropdown ];
    [dropdown setAction:selector(controlActioned:)];

    // filling the popup

    long i;
    for(i=0;i<3;i++)
    {
    [popup addItemWithTitle:"Hello"];
    NSMenuItem* item = [dropdown lastItem];
    [dropdown setEnabled:true];
    [item setTarget: dropdown ];
    [item setAction:selector(controlActioned:)];
    }

    Does anyone know why the above doesn't work ?

    Is this a problem with Cocoa menus in Carbon apps ? I also noticed that the
    spellcheck menu of a NSTextView did not act on the view, but I haven't made
    further investigations yet.

    Thanks,

    Eric

    Eric VERGNAUD Guest

  2. #2

    Default Re: NSPopupMenuButton not working

    Ok,

    I've dived a little deeper and found that selecting an item in the popup,
    instead of calling the action target, sends a HICommand to the main Carbon
    event target.

    This looks like a bug, because obviously the app doesn't know what to do
    with this.

    Anyone got a clue ?

    Eric
    > Hi,
    >
    > I'm integrating Cocoa UI in a Carbon app.
    >
    > I'm creating UI elements on the fly. I'm struggling with NSPopupMenuButton.
    > The popup button displays properly, so does the popup, but the chosen item
    > in the popup doesn't get selected, and I don't receive any action from the
    > popup. Here is my code:
    >
    > // subclassing NSPopup
    >
    > interface XCocoaDropDown : NSPopUpButton {
    > }
    > - (IBAction)controlActioned:(id)sender;
    >
    >
    > // creating the popup
    >
    > NSRect rect = { { 100, 100 }, { 200, 24 } };
    > XCocoaDropDown* dropdown = [[XCocoaDropDown alloc] initWithFrame:rect];
    > [dropdown setTarget: dropdown ];
    > [dropdown setAction:selector(controlActioned:)];
    >
    > // filling the popup
    >
    > long i;
    > for(i=0;i<3;i++)
    > {
    > [popup addItemWithTitle:"Hello"];
    > NSMenuItem* item = [dropdown lastItem];
    > [dropdown setEnabled:true];
    > [item setTarget: dropdown ];
    > [item setAction:selector(controlActioned:)];
    > }
    >
    > Does anyone know why the above doesn't work ?
    >
    > Is this a problem with Cocoa menus in Carbon apps ? I also noticed that the
    > spellcheck menu of a NSTextView did not act on the view, but I haven't made
    > further investigations yet.
    >
    > Thanks,
    >
    > Eric
    >
    Eric VERGNAUD Guest

  3. #3

    Default Re: NSPopupMenuButton not working (solved)

    dans l'article BB88E3D5.11FD8%eric.vergnaudwanadoo.fr, Eric VERGNAUD à
    [email]eric.vergnaudwanadoo.fr[/email] a écrit le 13/09/03 15:10:

    Ok, found the bug:

    I was returning noErr in my main loop when receiving unhandled commands,
    that is command without a HICommand in them. I changed it to return
    eventNotHandledErr and now everything is ok.

    What a relief.

    > Ok,
    >
    > I've dived a little deeper and found that selecting an item in the popup,
    > instead of calling the action target, sends a HICommand to the main Carbon
    > event target.
    >
    > This looks like a bug, because obviously the app doesn't know what to do
    > with this.
    >
    > Anyone got a clue ?
    >
    > Eric
    >
    >> Hi,
    >>
    >> I'm integrating Cocoa UI in a Carbon app.
    >>
    >> I'm creating UI elements on the fly. I'm struggling with NSPopupMenuButton.
    >> The popup button displays properly, so does the popup, but the chosen item
    >> in the popup doesn't get selected, and I don't receive any action from the
    >> popup. Here is my code:
    >>
    >> // subclassing NSPopup
    >>
    >> interface XCocoaDropDown : NSPopUpButton {
    >> }
    >> - (IBAction)controlActioned:(id)sender;
    >>
    >>
    >> // creating the popup
    >>
    >> NSRect rect = { { 100, 100 }, { 200, 24 } };
    >> XCocoaDropDown* dropdown = [[XCocoaDropDown alloc] initWithFrame:rect];
    >> [dropdown setTarget: dropdown ];
    >> [dropdown setAction:selector(controlActioned:)];
    >>
    >> // filling the popup
    >>
    >> long i;
    >> for(i=0;i<3;i++)
    >> {
    >> [popup addItemWithTitle:"Hello"];
    >> NSMenuItem* item = [dropdown lastItem];
    >> [dropdown setEnabled:true];
    >> [item setTarget: dropdown ];
    >> [item setAction:selector(controlActioned:)];
    >> }
    >>
    >> Does anyone know why the above doesn't work ?
    >>
    >> Is this a problem with Cocoa menus in Carbon apps ? I also noticed that the
    >> spellcheck menu of a NSTextView did not act on the view, but I haven't made
    >> further investigations yet.
    >>
    >> Thanks,
    >>
    >> Eric
    >>
    >
    Eric VERGNAUD Guest

Similar Threads

  1. #38816 [Opn]: PHP code that was working perfectly recently stopped working.
    By mtoohee at gmail dot com in forum PHP Programming
    Replies: 0
    Last Post: September 13th, 09:41 PM
  2. Replies: 0
    Last Post: November 26th, 06:47 AM
  3. Data not working on Label but is working in Datagrid
    By KetanS in forum Macromedia Flex General Discussion
    Replies: 4
    Last Post: June 11th, 03:56 AM
  4. CFC not working
    By crosemffet in forum Macromedia Flex General Discussion
    Replies: 1
    Last Post: March 30th, 06:56 PM
  5. Working TableStyle Not Working on a Second DataGrid
    By psibertrip in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: May 7th, 04:57 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139