Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify NSComboBox to handle attributed strings #314

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions Source/NSComboBoxCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -1775,23 +1775,39 @@ - (NSString *) _stringValueAtIndex: (NSInteger)index
}
else
{
id object = nil;

if (_dataSource == nil)
{
NSLog(@"%@: No data source currently specified", self);
return nil;
}
else if ([_dataSource respondsToSelector:
@selector(comboBox:objectValueForItemAtIndex:)])
NSLog(@"%@: No data source currently specified", self);
}
else if ([_dataSource respondsToSelector:
@selector(comboBox:objectValueForItemAtIndex:)])
{
return [[_dataSource comboBox: (NSComboBox *)[self controlView]
objectValueForItemAtIndex: index] description];
}
else if ([_dataSource respondsToSelector:
@selector(comboBoxCell:objectValueForItemAtIndex:)])
object = [_dataSource comboBox: (NSComboBox *)[self controlView]
objectValueForItemAtIndex: index];
}
else if ([_dataSource respondsToSelector:
@selector(comboBoxCell:objectValueForItemAtIndex:)])
{
return [[_dataSource comboBoxCell: self
objectValueForItemAtIndex: index] description];
}
object = [_dataSource comboBoxCell: self objectValueForItemAtIndex: index];
}

if (object)
{
// Check for attributed string type and return actual string instead..
if ([object isKindOfClass: [NSAttributedString class]])
{
object = [object string];
}
else
{
object = [object description];
}

// Return the request object...
return object;
}
}

return nil;
Expand Down
Loading