Programatically pop-up a NSPopUpButtonCell in a NSTableView

  • I have a table view with a mix of text columns and pop-up columns.
    I'm using bindings and core data.

    To provide better keyboard navigation I would like that when pressing
    tab the focus would move through both the text cells and the pop-up
    cells. By default, the pop-up cells are skipped when tabbing and only
    the text fields are traversed.

    The closest to a solution I have come is the following. In a sub-
    class to NSTableView I intercept the "insertTab:" message and do the
    following:

    // row and col are the position of the cell to pop-up
    [self endEditing];
    NSRect frame = [self frameOfCellAtColumn:col row:row];
    NSPopupButtonCell *cell = [[[self tableColumns] objectAtIndex:col]
    dataCell];
    [cell performClickWithFrame:frame inView:self];

    This is working to the extent that I manage to intercept the tab when
    leaving the previous text cell, end the editing of that cell and pop-
    up a list of items. The problem is that the list only contains the
    current item, not the whole list which normally are fetched from the
    core data store using bindings.

    I tried to add an item manually using [cell addItemWithTile:@"Test"]
    and the new item is then shown, but it is not selectable!? Besides, I
    would much prefer I could get this to integrate properly with
    bindings and core data.

    So my question is, what is the best way to programmatically pop-up a
    NSPopButtonCell in a NSTableView while still getting it properly
    populated using bindings to core data?

    Best regards,
    Jacob Wallström
    http://ghostparksoftware.com

    On Feb 14, 2007, at 11:07 AM, <cocoa-dev-request...> wrote:

    > Welcome to the <Cocoa-dev...> mailing list! Please stay
    > on-topic ====================
    >
    > In 2005, over 26,000 messages were sent to the list.  In order to keep
    > the list useful and to maximise your chances of getting an answer to
    > your question, please stay on topic and adhere to the guidelines given
    > in:
    >
    > &quot;How To Ask Questions The Smart Way&quot;
    > &lt;http://www.catb.org/~esr/faqs/smart-questions.html&gt;
    >
    > If someone posts a message that is off-topic, please do not reply to
    > the list.  You should contact the sender directly or alert a
    > moderator.  If a moderator flags a thread as closed (typically with
    > &quot;EOT&quot; in the subject line), do not continue to post to that
    > thread.
    >
    > If you post a message that is blatantly off-topic, you are liable to
    > be suspended.
    >
    >
    > **** Other Apple mailing lists that may be relevant are listed at:
    > &lt;http://lists.apple.com/mailman/listinfo&gt;
    > in particular see:
    > Xcode-users:
    > &lt;http://lists.apple.com/mailman/listinfo/xcode-users&gt;
    >
    > The Omni Group hosts a general Mac OS X developer list:
    > &lt;http://www.omnigroup.com/mailman/listinfo/macosx-dev&gt;
    >
    > There is a Yahoo Group for discussion of business-related issues at:
    > &lt;http://groups.yahoo.com/group/macsb/&gt;
    >
    >
    >
    > Do not abuse your NDA =========================
    >
    > Do not discuss Mac OS X Leopard development related issues on this
    > list.  Mac OS X Leopard seeds are made available to you under NDA and
    > you are not allowed to discuss them on any public mailing list.
    >
    >
    > List etiquette ==============
    >
    > When you post a message, bear in mind that you are asking several
    > thousand people to listen to what you're saying.  In addition to the
    > guidelines given in &quot;How To Ask Questions The Smart Way&quot;,
    > please ensure that you abide by the list rules:
    >
    > &lt;http://lists.apple.com/tc.html&gt;
    > &lt;http://lists.apple.com/tips.html&gt;
    > In particular: please &quot;Edit included messages in replies
    > to
    > minimize the amount of text.&quot;  There is no need, for
    > example,
    > to include the list footer in your reply.
    >
    >
    > **** Before posting a question, please check the list archives (see
    > &quot;Online resources&quot; below) and try searching Google.  Many
    > questions have been asked before and have already been answered.
    >
    > **** When you ask a question, whenever possible please:
    >
    > 1. Describe what your high-level goal is
    > 2. Include any relevant code
    > 3. If appropriate, include URLs to screenshots
    >
    > For more details, see:
    >
    > &lt;http://www.catb.org/~esr/faqs/smart-questions.html&gt;
    > and
    > &lt;http://www.mikeash.com/getting_answers.html&gt;
    >
    >
    > If you post a message to the list and do not get a reply, you
    > should not simply repost the message.
    > There may be reasons why no-one has answered, see the references
    > above.
    > If you want to send again, add more information or background, or
    > explain what further steps
    > you have taken in the interim to solve your problem.
    >
    >
    > Note that you should never post to the list any message that was
    > sent to you
    > privately unless you have the original author's permission.
    >
    >
    >
    > Cocoa-related resources =======================
    >
    > Cocoa-related resources that may answer your question without the need
    > to wait for a reply from the list:
    >
    >
    > Apple's documentation ---------------------
    >
    > The Cocoa Getting Started page.
    > If you haven't read any Cocoa documentation and want to learn
    > about
    > the technology, you should begin with this.
    > &lt;http://developer.apple.com/referencelibrary/GettingStarted/
    > GS_Cocoa/&gt;
    >
    >
    >
    > Main documentation links:
    > &lt;http://developer.apple.com/documentation/&gt;
    > &lt;http://developer.apple.com/documentation/Cocoa/Cocoa.html&gt;
    >
    >
    > Apple produces several kinds of documentation.  For an overview of how
    > to use the documentation, see:
    >
    > &lt;http://developer.apple.com/referencelibrary/
    > usingreflib.html&gt;
    >
    >
    > and
    > &lt;http://developer.apple.com/macosx/newinreflibrary.html&gt;
    >
    > * Finding documentation
    >
    > If you are not sure where to find documentation relevant to your
    > problem, a useful strategy is to go to the API reference for a
    > relevant class and look at its companion document.  You can also
    > search the online documentation suite using the search field at the
    > top right of the page (see, for example,
    > &lt;http://developer.apple.com/documentation/Cocoa/index.html&gt;). It
    > is often a good idea to check the &quot;Restrict to Cocoa&quot; box.
    > If you need more precise search, you can use the Advanced Search panel
    > at &lt;http://developer.apple.com/search/&gt;.
    >
    > Remember you can also view and search the documentation in Xcode --
    > see the &quot;Help&quot; menu.  You can see all the methods associated
    > with a class (and links to relevant documentation) using Xcode's Class
    > Browser (see the Project &gt; Class Browser menu item).  In Xcode, you
    > can Option-double-click on a symbol to look it up in the
    > documentation, and you can Command-double-click on a symbol to go to
    > the header file in which it is declared.
    >
    >
    > * Keeping documentation up-to-date
    >
    > You can keep your local documentation up-to-date by using the
    > Documentation update preference in Xcode.  Apple's developer
    > documentation is updated en bloc about once a month.  An update
    > package is made available at about the same time that updates are
    > published on the web site.
    >
    >
    >
    > Code examples -------------
    >
    > Apple provides code samples in two places, on-disk (installed with the
    > developer tools) and online:
    >
    > Developer examples
    > &lt;file:///Developer/Examples/AppKit/&gt;
    >
    > ADC
    > &lt;http://developer.apple.com/samplecode/&gt;
    >
    >
    > Online resources ----------------
    >
    > &quot;UNOFFICIAL Cocoa-dev Frequently Asked Questions&quot;
    > &lt;http://www.alastairs-place.net/cocoa/faq.txt&gt;
    > Especially useful for pointers to documents relating to memory
    > management
    > and book recommendations
    >
    >
    > List archives
    > &lt;http://lists.apple.com/archives/cocoa-dev&gt;
    >
    >
    > Combined Apple and Omni Cocoa developer list archives
    > &lt;http://www.cocoabuilder.com/&gt;
    >
    >
    > Cocoa-related sites
    > &lt;http://www.cocoadev.com/&gt;
    > &lt;http://www.cocoadevcentral.com/&gt;
    > &lt;http://www.stepwise.com/&gt;
    >
    >
    > Cocoa Bindings
    > &lt;http://developer.apple.com/documentation/Cocoa/Conceptual/
    > CocoaBindings/&gt;
    >
    >
    > &lt;http://developer.apple.com/documentation/Cocoa/Reference/
    > CocoaBindingsRef/&gt;
    >
    >
    > &lt;http://developer.apple.com/cocoa/cocoabindings.html&gt;
    > &lt;http://homepage.mac.com/mmalc/CocoaExamples/
    > controllers.html&gt;
    >
    >
    > &lt;http://www.cocoadevcentral.com/articles/000080.php&gt;
    > &lt;http://www.macdevcenter.com/pub/a/mac/2004/04/06/
    > cocoa.html&gt;
    >
    >
    >
    >
    > Google
    > &lt;http://www.google.com/&gt;
    > (It is sometimes the case that using the subject line of a post as
    > a search term in
    > Google will yield an answer.  If this is the case, you have
    > probably not invested sufficient
    > effort into finding an answer to your problem, and you are likely
    > to receive a reprimand.)
    >
    >
    > Memory management -----------------
    >
    > Developers are strongly discouraged from attempting to reformulate
    > Cocoa's memory management rules in posts to the list.  Almost
    > invariably, someone makes a subtle or not-so-subtle mistake which then
    > results in confusion and additional messages to resolve the issue.
    > Simply post links to the relevant documentation, such as:
    > &lt;http://developer.apple.com/documentation/Cocoa/Conceptual/
    > MemoryMgmt/Tasks/MemoryManagementRules.html&gt;
    >
    >
    > Links to other reviewed articles that discuss memory management are
    > given in &lt;http://www.alastairs-place.net/cocoa/faq.txt&gt;
    >
    >
    >
    >
    > To post to this list, send your email to:
    >
    > <cocoa-dev...>
    >
    > General information about the mailing list is at:
    >
    > http://lists.apple.com/mailman/listinfo/cocoa-dev
    >
    > If you ever want to unsubscribe or change your options (eg, switch to
    > or from digest mode, change your password, etc.), visit your
    > subscription page at:
    >
    > http://lists.apple.com/mailman/options/cocoa-dev/jacob.wallstrom%
    > 40ghostparksoftware.com
    >
    >
    > You can also make such adjustments via email by sending a message to:
    >
    > <Cocoa-dev-request...>
    >
    > with the word `help' in the subject or body (don't include the
    > quotes), and you will get back a message with instructions.
    >
    > You must know your password to change your options (including changing
    > the password, itself) or to unsubscribe.  It is:
    >
    > mataappl
    >
    > Normally, Mailman will remind you of your lists.apple.com mailing list
    > passwords once every month, although you can disable this if you
    > prefer.  This reminder will also include instructions on how to
    > unsubscribe or change your account options.  There is also a button on
    > your options page that will email your current password to you.
previous month february 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28        
Go to today