update variable + string value of a pull-down menu

I’m waiting on my Obj-C book to arrive. In the mean time, I’ve got a couple questions that will be beneficial to me and others.

  1. I have a text field who’s value is a variable “theQuery”. It is bound but the variable is not sent until I hit enter or exit the text field (Sent on end edit). I need it to set after each character change. I have found controlTextDidChange as mentioned in a previous post and that much is working but I can’t figure out how to actually update the variable. Do I need to send a return keystroke or something in the on controlTextDidChange_(Notification)
    block?

  2. How do I get the string value of a drop down menu?

Thanks for your help. As moronic as I may sound, I think I am actually making some decent progress.

You’re confusing two issues here. Text fields can send an action, and this can be set to happen either Sent on End Editing or Sent on Enter Only, via the Attributes Inspector. The latter means the action, if you connect one, will be sent when you tab or click out of the field; the former means it will only be sent when you hit the return key. Neither is to do with bindings.

If you go to the Bindings Inspector, you’ll see a checkbox Continuously Updates Value; clicking that will make the value of the variable change continuously.

You’ll need to explain further.

Oh my gosh, I can’t believe I overlooked that. Thank you!

Sure, its actually the NSPopUpMenu. I used to do this:

set productType to title of current menu item of popup button "productMenu" of window 1

How would I do the equivalent in ASOC?

Thanks again for your help!

EDIT: I just found “- (NSString *)titleOfSelectedItem”. This is what I’m looking for I believe but I’m not sure how to implement it?


set productType to productMenu's titleOfSelectedItem()

There are many things you can do with a NSPopUpButton.
Check out the docs.

Regards,

Craig

Thank you guys for the help! Craig, especially you for those great tutorials I’m working thru. Keep up the great work!

You would have a property that you connect in IB to represent the popup, let’s say thePopup. Then you’d use:

set theChoice to titleOfSelectedItem’s titleOfSelectedItem()

But if you populate the popup via bindings, you can have a property bound to the selection via an array controller, and then you have to do nothing – it reflects the value automatically.