Proper implementation of setChoices:

This will now reload the table view and resize the pop-up (if necessary).
This commit is contained in:
Allan Odgaard
2012-09-04 18:16:39 +02:00
parent 949c074f9d
commit b136fcbca4

View File

@@ -75,6 +75,21 @@ enum action_t { kActionNop, kActionTab, kActionReturn, kActionCancel, kActionMov
return choiceIndex == NSNotFound ? nil : [choices objectAtIndex:choiceIndex];
}
- (void)setChoices:(NSArray*)newChoices
{
if([choices isEqualToArray:newChoices])
return;
id oldSelection = self.selectedChoice;
self.choiceIndex = NSNotFound;
[choices autorelease];
choices = [newChoices retain];
[tableView reloadData];
self.choiceIndex = [choices indexOfObject:oldSelection];
[self sizeToFit];
}
- (void)setChoiceIndex:(NSUInteger)newIndex
{
if(choiceIndex != newIndex)