Interface Replication Question

I have been trying to figure out how to replicate an interface feature found in Mail.app. When entering a name (or email address) in the “To:” text field, if multiple possibilites exist a menu drops down from the text field. I have been trying to replicate this using combo boxes, but so far, I haven’t been able to make this work the way I want it to. Does anybody know how to do this?

Thanks in advance,
Brad Bumgarner, CTA

Can you post the code you’re having problems with and tell us what the effects are (errors, not working right because {fill in the blank})?

You should be able to implement something like this, according to the AppleScript Studio Terminology Reference (available through the Help menu in Xcode/Project Builder). As for setting items in the combo box, this is what the ASTR says:

Brad,

I created a combo box called “combox” (ok, not original :P) and clicked the “will pop up” checkbox, then created this handler:

on will pop up theObject
	make new combo box item at end of combo box items of combo box "combox" of window "Tester" with data "hello"
	make new combo box item at end of combo box items of combo box "combox" of window "Tester" with data "hello2"
	make new combo box item at end of combo box items of combo box "combox" of window "Tester" with data "hello3"
end will pop up

and it seemed to work like what you want. Now, it adds to the items listed, so if you want to wipe out the previous items, you need to delete them before doing the “make new…” lines.

Kevin,

It turns out that I need to use NSTokenFields to accomplish the user interface that I need. Since there is no documentation of these fields in the Applescript Studio Reference I can only assume that no hooks have been made for Applescript as of yet. SO, that being said, I will start on an Obj-C solution.

To answer your question(s). Creating the combo box menu items was never a problem. The autofill wouldn’t and the menu won’t automatically drop down while typing.

Not directly related to THIS thread, I noticed you posted a portion of the Studio Ref. regarding combo boxes. I read that section many times yesterday (:)) and noticed that there is a “current item” property that is a 1-based integer AND it is read/write capable. Unfortunately I wasn’t able to figure out the correct syntax to set a combo box to a given item. (I went a different route instead :))

Thanks for your reply,
Brad Bumgarner, CTA

You must attach a menu to a token field. I have yet to discover how to do this in AS Studio. [edit] Brad, anything you come up with on this would be greatly appreciated. See my previous post: http://bbs.applescript.net/viewtopic.php?id=17203

Since token fields are not a supported control in AS Studio, I have to ask the obvious question: What is a token field?

Glad you guys are on the same page, though. :cool: