• 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
NSComboBox, binding, multiple selection, multiple values == trouble
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSComboBox, binding, multiple selection, multiple values == trouble


  • Subject: NSComboBox, binding, multiple selection, multiple values == trouble
  • From: Markus Spoettl <email@hidden>
  • Date: Wed, 23 Jan 2013 18:28:23 +0100

Hello,

in my app, I can edit a selection of model objects in a window which that consists of NSTextFields and NSComboBoxes to edit model properties, all via binding to an NSArrayController's selection proxy.

When I'm editing a multi-selection that has property values are different for individual model objects in the selection, I get an undesired behavior from NSComboBox:

When I tab over an NSComboBox which displays the multiple-values placeholder, upon exiting the combo box, the corresponding property for all selected objects is nil'd. (BAD)

When I do the same (tabbing over) with an NSTextField, the values of the individual objects' properties are unchanged. (GOOD).

Since I have no control over how NSComboBox implements its bindings and I therefore can't fix the handling of multi-valued selections, I fixed this by subclassing NSComboBox and implementing -objectValue by returning the NSMultipleValuesMarker object as I see fit.

- (id)objectValue
{
    id result = [super objectValue];
    if (returnMultiValuesMarkerForEmptyObjectValue) {
        if ([result isEqualTo:@""])  {
            result = NSMultipleValuesMarker;
        }
    }
    return result;
}

The private returnMultiValuesMarkerForEmptyObjectValue ivar is set to YES externally by my editor controller which knows that a multiple selection is being edited.

This works reasonably well but I wonder how others have fixed this problem. I feel returning NSMultipleValuesMarker is a hack which works only because NSComboBox thinks it's a legitimate return value (or doesn't care). The fact that I can't clear properties for multiple selections is a side effect I can live with.

Any better fixes for this?

Regards
Markus
--
__________________________________________
Markus Spoettl
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: NSComboBox, binding, multiple selection, multiple values == trouble
      • From: Keary Suska <email@hidden>
    • Re: NSComboBox, binding, multiple selection, multiple values == trouble
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Best guess at expressing a string as a variable
  • Next by Date: Re: Using NSSavePanel to export to UTTypeFolder without a file extension.
  • Previous by thread: Re: Best guess at expressing a string as a variable
  • Next by thread: Re: NSComboBox, binding, multiple selection, multiple values == trouble
  • Index(es):
    • Date
    • Thread