PopUpButton with a custom apparence using an image

  • Hi all,

    I wolud like to use a custom Button that performs like a PullsDown button
    (NSPopUpButton) but using an image instead of standard PopUpButton
    apparence form IB.
    I can create a button image using NSButton class. But I can't do the same
    using NSPopUpButton Class.
    I think that a possible way is to subclass NSPopUpButton, but I'm new to
    cocoa and I don't know if this is the right way.
    I'm looking for some suggestion or examples about this.

    TIA,

    Alessandro
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • Have you looked at "/Developer/Examples/AppKit/MenuMadness"?

    j o a r

    On onsdag, september 3, 2003, at 03:45 PM, Alessandro de Peppo wrote:

    > I wolud like to use a custom Button that performs like a PullsDown
    > button
    > (NSPopUpButton) but using an image instead of standard PopUpButton
    > apparence form IB.
    > I can create a button image using NSButton class. But I can't do the
    > same
    > using NSPopUpButton Class.
    > I think that a possible way is to subclass NSPopUpButton, but I'm new
    > to
    > cocoa and I don't know if this is the right way.
    > I'm looking for some suggestion or examples about this.
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
  • At 16:28 +0200 3-09-2003, j o a r wrote:
    > Have you looked at "/Developer/Examples/AppKit/MenuMadness"?
    >
    > j o a r

    Thanks joar! :-)
    I was able to realize my custom PopUpButton very quickly, without any subclass.
    But there is one little problem: I can't set an alternate image (or just an
    highlight) on my button to have some feedback when button is pressed and
    menu is displayed.
    here's my code snippet:

    - (void)createPullDownMenu
    {
        NSMenuItem *item;

        pullDown = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(124.0,
    ([[window contentView] frame].size.height - 44.0), 78.0, 34.0)
    pullsDown:YES];

        [[pullDown cell] setBordered:NO];
        [[pullDown cell] setImagePosition:NSImageOnly];
        [[pullDown cell] setArrowPosition:NSPopUpNoArrow];

        [pullDown addItemsWithTitles:[NSArray arrayWithObjects:@"title",
    @"One", @"Two", @"Three", @"Four", @"Five", @"Six", @"Seven", @"Eight",
    @"Nine", @"Ten", @"Eleven", @"Twelve", @"Thirteen", @"Fourteen",
    @"Fifteen", nil]];
        [[pullDown cell] setUsesItemFromMenu:NO];
        item = [[NSMenuItem allocWithZone:[self zone]] initWithTitle:@""
    action:NULL keyEquivalent:@""];
        [item setImage:[NSImage imageNamed:@"Pop"]];
        [item setOnStateImage:nil];
        [item setMixedStateImage:nil];
        [[pullDown cell] setMenuItem:item];
        [item release];
        [pullDown setPreferredEdge:NSMinXEdge];
        [[[pullDown menu] menuRepresentation] setHorizontalEdgePadding:0.0];
        [[window contentView] addSubview:pullDown];
    }

    Any ideas?

    TIA,

    Alessandro
    _______________________________________________
    cocoa-dev mailing list | <cocoa-dev...>
    Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
    Do not post admin requests to the list. They will be ignored.
previous month september 2003 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          
Go to today