Tuesday, December 12, 2017

#1 2009-09-18 01:05:27 pm

evocomps
Member
From:: Oklahoma
Registered: 2007-10-15
Posts: 119
Website

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.

Offline

 

#2 2009-09-18 06:28:49 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: update variable + string value of a pull-down menu

evocomps wrote:

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.


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.

evocomps wrote:

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


You'll need to explain further.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2009-09-18 09:18:00 pm

evocomps
Member
From:: Oklahoma
Registered: 2007-10-15
Posts: 119
Website

Re: update variable + string value of a pull-down menu

Shane Stanley wrote:

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.


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

Shane Stanley wrote:

You'll need to explain further.


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

Applescript:

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?

Last edited by evocomps (2009-09-18 09:26:41 pm)

Offline

 

#4 2009-09-18 09:25:51 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: update variable + string value of a pull-down menu

Applescript:


set productType to productMenu's titleOfSelectedItem()

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

Regards,

Craig

Offline

 

#5 2009-09-18 09:33:23 pm

evocomps
Member
From:: Oklahoma
Registered: 2007-10-15
Posts: 119
Website

Re: update variable + string value of a pull-down menu

Craig Williams wrote:

Applescript:


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!

Offline

 

#6 2009-09-18 10:48:42 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: update variable + string value of a pull-down menu

evocomps wrote:

This is what I'm looking for I believe but I'm not sure how to implement it?


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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)