• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Setting the starting index of an NSComboBox
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the starting index of an NSComboBox


  • Subject: Re: Setting the starting index of an NSComboBox
  • From: Fritz Anderson <email@hidden>
  • Date: Thu, 29 Jun 2006 13:50:00 -0500

On 23 Jun 2006, at 3:13 PM, Steve Hunt wrote:

I am just starting with Cocoa and I am having a problem in setting the starting index of a NSComboBox control. On startup, the index is not set although the first item is displayed. You have to make a selection to enable the combo box and set an index. In my app, I would like the first item to be selected on startup. I assume the following code:

[calcTypeField selectItemAtIndex:0];

will work, but I cannot determine where to place the code to effect the selection on startup.

You know how to spell "effect;" I like the cut of your jib.

You are no doubt aware of this:
When you set or retrieve a combo box’s value with the standard NSControl methods (such as setStringValue:, stringValue, setFloatValue:, and floatValue), you’re setting or retrieving the value of the combo box’s text field, and not the current selection of the list. Programmatically changing the combo box’s value does not change what’s selected in the combo box’s list. Conversely, programmatically changing what’s selected in the list does not change the text field’s value. If you want the text field value and the list selection to match up, you need to set them individually.
In other words, a combo box is a text field, not a popup menu. When you follow George's advice to initialize in -awakeFromNib, you have to set both item and text if that's what you want.

<http://developer.apple.com/documentation/Cocoa/Conceptual/ComboBox/ Tasks/SettingComboBoxValue.html>

	-- F

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Setting the starting index of an NSComboBox (From: Steve Hunt <email@hidden>)

  • Prev by Date: Re: NSImage bug? NEF Files.
  • Next by Date: Can't cache image
  • Previous by thread: Re: Setting the starting index of an NSComboBox
  • Next by thread: Off-Topic: Communicating with users
  • Index(es):
    • Date
    • Thread