Grant Wilkinson Grant Wilkinson - 1 year ago 1041
Objective-C Question

Create NSPopUpButton Programmatically

How can I create an

programmatically and attach the menu items to it? This is what I have so far but it is not click able nor does it have any menu items attached

help window is just the name of my

NSPopUpButton *button = [[NSPopUpButton alloc] initWithFrame:NSMakeRect(10, 0, 50, 50)];
[[helpWindow contentView] addSubview:button];
[button setNeedsDisplay:YES];

Answer Source

Use the designated initializer initWithFrame:pullsDown:, and then use addItemWithTitle: or addItemsWithTitles: to add the menu items

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download