I have an NSComboBox in a NSToolbar and I want the combo box to send messages to its datasource and delegate.
My class adopts the NSComboBoxDelegate
and NSComboBoxDataSource
protocols. I create my combo box like this
NSRect comboBoxRect = NSMakeRect(0, 0, 175, 20);
NSComboBox *sourceComboBox = [[NSComboBox alloc] initWithFrame:comboBoxRect];
[sourceComboBox setDataSource:self];
[sourceComboBox setDelegate:self];
[sourceComboBox setUsesDataSource:YES];
[sourceComboBox setEditable:NO];
NSToolbarItem *sourceComboBoxItem = [[NSToobarItem alloc] initWithItemIdentifier:@"MyID"];
[sourceComboBoxItem setView:sourceComboBox];
[sourceComboBoxItem setMinSize:NSMakeSize(175*1.2, SEGMENT_HEIGHT)];
[sourceComboBoxItem setMaxSize:NSMakeSize(175*1.2, SEGMENT_HEIGHT)];
[sourceComboBoxItem setDelegate:self];
[sourceComboBoxItem setTag:4];
I also implement the following datasource and delegate methods had have break points in them, but nothing is being sent to those methods.
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)index;
- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox;
- (void)comboBoxSelectionDidChange:(NSNotification *)notification;
Any suggestions on what I may be doing wrong? Thank you.