• 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
Popups in table views Was: How to bind this situation?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Popups in table views Was: How to bind this situation?


  • Subject: Popups in table views Was: How to bind this situation?
  • From: John Timmer <email@hidden>
  • Date: Mon, 12 Sep 2005 22:36:39 -0400

Replying to myself with a partial solution (described below), and an ongoing
problem which I¹m looking for help with:

I figured that I could create and bind the popup without any problem, which
I did.  The problem is that it can¹t seem to maintain a selection.  When
changing the selection, it flashes briefly on the new one and then reverts
to a blank item.  Clicking on it reveals all the appropriate choices.
Binding the selection to just about anything fails (in most cases, the
object¹s description shows up).

The code for the column creation/binding is:

    NSArrayController *theController = [[NSArrayController alloc] init];
    [theController bind: @"managedObjectContext" toObject: theDocument
withKeyPath: @"managedObjectContext" options: nil];

    [theController bind: @"contentSet" toObject: theDescription withKeyPath:
@"possibleOptions" options: nil];

    NSPopUpButtonCell *theCell = [[[NSPopUpButtonCell alloc] initTextCell:
@"" pullsDown: NO] autorelease];
    [theCell setBordered:NO];

    NSMutableDictionary *theOptions = [NSMutableDictionary dictionary];
    [theOptions setObject: [NSNumber numberWithBool: YES] forKey:
@"NSInsertsNullPlaceholder"];
    [theOptions setObject: [NSNumber numberWithBool: YES] forKey:
@"NSRaisesForNotApplicableKeys"];
    [theOptions setObject: @"Unknown" forKey: @"NSNullPlaceholder"];

    [theCell bind: @"content" toObject: theController withKeyPath:
@"arrangedObjects" options: theOptions];
    [theCell bind: @"contentObjects" toObject: theController withKeyPath:
@"arrangedObjects" options: theOptions];
    [theCell bind: @"contentValues" toObject: theController withKeyPath:
@"arrangedObjects.name" options: theOptions];




My solution for how to work a connection into the appropriate one of a
number of possible items in a to-many relationship was to bind the selection
to a dummy key that would allow me to identify which of the to-many set was
needed.  I then overrode ³valueForUndefinedKey:²  and used the key passed to
return the appropriate option out of the correct member of the set.  It
seems to work okay based on NSLogging, but since I can¹t get the popup to
hold a selection, it¹s not clear how effective this is overall.

JT




> Let me describe my object graph:
>
> An item contains a set of "holding" objects.  The holder contains a
> reference to one of a user-defined set of descriptor objects, which has a
> set of options.  The holder also has a variable that references which one of
> those options the user chose.  There are corresponding links back so that
> notifications about changes can be propagated back (key/value observing
> would crash the app on undo).
>
> Item -- set --> holder  ---------> description
>      <---------   |    <-- set  --        |
>                   |                       |
>              chosen option ------->   options
>
> Here's the problem:  There's a table view that lists all the items.  I'm
> getting requests to allow the user to add columns for some of the descriptor
> items that would display the chosen option (it seems most sensible to make
> this as a popup menu of all available options, so the users can change the
> option while in list view).
>
> I can figure out how to create a new table column and a popup menu cell and
> bind the menu options to the description's options.  The problem I have is
> how to bind the chosen option.  A given item may or may not have a reference
> to a given holder.description, and it may have dozens of holders all
> pointing to different descriptions.  Given an array controller filled with
> items, how do I select the right holder for the column, which is bound to
> the description?
>
 _______________________________________________
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: 
 >How to bind this situation? (From: John Timmer <email@hidden>)

  • Prev by Date: indicating window is miniaturized
  • Next by Date: Re: Final attempt regarding core data / opengl...
  • Previous by thread: How to bind this situation?
  • Next by thread: NSApp runModalSession: problem
  • Index(es):
    • Date
    • Thread