I’m trying to get the typed in item from a Combo Box and finding it difficult.
I want the user to be able to build a list of email addresses, but can’t even get the first typed in address.
I’ve tried lots of items from the book ‘Cocoa in a Nutshell’ as well as some from the Developer notes, but nada.
Can anyone give me some clues as to what I need to do to proceed please.
Regards
Santa
on SetCCMailRecipients_(sender)
try
set SelectedUser to (CCMailRecipients's itemObjectValueAtIndex_(0)) as text
display dialog SelectedUser
on error errmsg
display dialog errmsg
end try
end SetCCMailRecipients_
Unfortunately I can’t get it to work. t errors with ‘no value for t’ when i enter something into the combo box ‘CCMailRecipients’. I don’t know enough about Studio to understand what I’m doing wrong, and hours of reading haven’t helped.
Regards
Santa
on SetCCMailRecipients_(sender)
try
set t to CCMailRecipients's stringValue_()
--set SelectedUser to (CCMailRecipients's objectValues()) as list
display dialog t
on error errmsg
display dialog errmsg
end try
end SetCCMailRecipients_
Every things OK, I re-inserted the ComboBox and re-built the bindings, to no avail. I created a new project just with a combobox and pasted the script in, nada.
I changed the routines title ‘SetCCMailRecipients_’ to a shorter one and rebuilt the bindings and what do you know, it works!
Is there a limit on the title length for routines?
It’s certainly not the cause of your problem, but it’s recommended to consider the Cocoa naming conventions.
Method names should start with a lowercase character, class names with an uppercase character