Cocoa programming help

Posted on 2006-05-03
Last Modified: 2013-12-26
Hi everybody,
           i am building a cocoa application in objective C wherein there is a NSToolbar with different items on it. My problem is that I can't figure out how to associate shortcut keys to those items. I will be extremely thankful if any sort of suggestions are given on how to add a shortcut key association with an NSToolbar item,

Thanking in advance,
Question by:Avik77
    LVL 23

    Accepted Solution

    You need to associate an NSMenuItem with the NSToolbarItems that have key equivalents.
    You assign a key equivalent using [NSMenuItem setKeyEquivalent:] and [NSMenuItem setKeyEquivalentModifierMask:],  then assign that NSMenuItem to the NSToolbarItem using [NSToolbarItem setMenuFormRepresentation:].  I don't know if this will work if the NSMenuItem is not actually part of a NSMenu, but it would be considered poor UI design if your toolbar actions could not be invoked via the menus anyway.

    LVL 23

    Expert Comment

    Did this work for you?

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
    Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
    This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now