is there an IBAction for item selection in NSComboBox?
I trying to define 2 different actions - one for item selected from the drop box, and another action for entering a new value. is that possible?
*I'm doing a mac app, not iOS
is there an IBAction for item selection in NSComboBox?
I trying to define 2 different actions - one for item selected from the drop box, and another action for entering a new value. is that possible?
*I'm doing a mac app, not iOS
so I added this code to my viewController.m:
-(void)comboBoxSelectionDidChange:(NSNotification *)notification{
NSLog(@"comboBoxSelectionDidChange");
}
- (void)controlTextDidEndEditing:(NSNotification *)aNotification{
NSLog(@"controlTextDidEndEditing");
}
Then, connected my combobox "cmbbox" to the delegate on viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
self.cmbbox.delegate = self;
}
and finally, added the NSComboBoxDelegate delegate protocol to viewController.h header file:
@interface ViewController : NSViewController <NSComboBoxDelegate>
I believe you can distinguish between the two events in your delegate, but not through an
IBAction
. TheNSComboBoxDelegate
protocol responds to the selector- (void)comboBoxSelectionDidChange:(NSNotification *)notification
. You can use this to determine when an item was selected from the drop box, and use the text editing delegate selector- (void)controlTextDidEndEditing:(NSNotification *)aNotification
to determine when the user entered text directly.