MRoig
May 4, 2010, 4:09pm
#1
What’s the best way to change all the items in a NSPopup Button?
I tried this:
myPopUpButton's removeAllItems
myPopUpButton's addItemsWithTitles_(listOfNewItems)
But it doesn’t get past the first line. In the console I get: “Can’t get removeAllItems of «class ocid» id «data kptr00000000A02F610002000000»”
Actually, it does remove all the items in my NSPopup Button, but then throws this error.
MRoig
May 4, 2010, 4:26pm
#2
As a little aside, I have been able to get it to work like so:
try
myPopUpButton's removeAllItems
end
myPopUpButton's addItemsWithTitles_(listOfNewItems)
But I’m not entirely happy with that. I’d rather not have an error in there.
myPopUpButton's removeAllItems()
MRoig
May 5, 2010, 5:01pm
#5
Actually, today I had trouble reading the state of a button.
this throws all sorts of errors:
myButton's |state()|
This works fine:
myButton's |state|
So why doesn’t this need the empty brackets when “removeAllItems()” does?
MRoig
May 5, 2010, 5:11pm
#7
I see. What’s confusing me is that some methods don’t throw an error when you don’t include the brackets, like “state”, but other do, like “removeAllItems”.
It’s al much more clear now. Thanks