stringValue/indexOfSelectedItem in NSComboBox returning wrong values.
stringValue/indexOfSelectedItem in NSComboBox returning wrong values.
- Subject: stringValue/indexOfSelectedItem in NSComboBox returning wrong values.
- From: "Cameron Hotchkies" <email@hidden>
- Date: Wed, 7 May 2008 19:45:08 -0500
Hi all,
In an app I'm working on, I need a ComboBox that pulls it's contents
from a database. I did this by attaching a datasource. I have the
(case insensitive) autocomplete working, everything seemed to be going
well. My datasource class implements the following functions:
- (id)comboBox:(NSComboBox *)aComboBox
objectValueForItemAtIndex:(NSInteger)index;
- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox;
- (NSString *)comboBox:(NSComboBox *)aComboBox
completedString:(NSString *)uncompletedString;
- (NSUInteger)comboBox:(NSComboBox *)aComboBox
indexOfItemWithStringValue:(NSString *)aString;
With NSLog() calls, I've verified they appear to be working correctly
(including the indexOfItemWithStringValue: selector)
The problem I've been having is the following calls (detailsUsername
is an NSComboBox*):
NSLog(@"Looks like you chose #%d: %@ %@", [detailsUsername
indexOfSelectedItem], [detailsUsername objectValueOfSelectedItem],
[detailsUsername stringValue]);
produce:
Looks like you chose #0: (null) (null)
if this NSLog() is in the comboBoxSelectionDidChange: function, and I
replace the actual ComboBox with the casted notification argument, it
appears stringValue works, and -1 is the returned index. But any
attempts to call selectItemAtIndex: fail to change the selected index
value.
Is this something that should automatically be working? or is it
standard to have to catch this in the comboBoxSelectionDidChange
delegate?
And is there something obvious I'm missing as to why this is not
changing the selection?
Thanks.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden