Toolbar item with popup menu

  • Hello.

    In my Cocoa application, I want to have toolbar items with popup
    menus, just like the ones in Xcode. Does NSToolbar provide this kind
    of behavior as standard functionality? If not, can the behavior of
    NSToolbarItem be customized the way I need? And, finally, maybe
    someone has already done the trick, and there's already some open
    source / sample code?

    Thank you in advance!

    Best regards,
    Sergey Shapovalov.
  • On Oct 3, 2007, at 4:30 AM, Sergey Shapovalov wrote:

    > Hello.
    >
    > In my Cocoa application, I want to have toolbar items with popup
    > menus, just like the ones in Xcode. Does NSToolbar provide this kind
    > of behavior as standard functionality? If not, can the behavior of
    > NSToolbarItem be customized the way I need? And, finally, maybe
    > someone has already done the trick, and there's already some open
    > source / sample code?

    Search Xcode for "toolbar popup".  You'll be pointed to the
    "ToolbarSample" on the Apple web page.

    http://developer.apple.com/samplecode/ToolbarSample/index.html

    As a general reminder to everyone, please use the search functionality
    in Xcode and try Google before posting here.  Thanks
  • Scott,

    thank you very much for the reply.

    On Oct 3, 2007, at 12:43 PM, Scott Anguish wrote:

    >
    > On Oct 3, 2007, at 4:30 AM, Sergey Shapovalov wrote:
    >
    >> Hello.
    >>
    >> In my Cocoa application, I want to have toolbar items with popup
    >> menus, just like the ones in Xcode. Does NSToolbar provide this
    >> kind of behavior as standard functionality? If not, can the
    >> behavior of NSToolbarItem be customized the way I need? And,
    >> finally, maybe someone has already done the trick, and there's
    >> already some open source / sample code?
    >
    >
    > Search Xcode for "toolbar popup".  You'll be pointed to the
    > "ToolbarSample" on the Apple web page.
    >
    > http://developer.apple.com/samplecode/ToolbarSample/index.html
    >
    >
    > As a general reminder to everyone, please use the search
    > functionality in Xcode and try Google before posting here.  Thanks

    I'll definitely learn how this sample works. However, it does not
    provide exactly what I need: a button in toolbar, from which a popup
    menu will drop if the user clicks the button and holds it for a
    while. In other words, what I need is exactly the same behavior as
    implemented in Xcode windows. But I hope that having learned the
    sample you have pointed to, I'll find a hint towards how to implement
    what I need.

    Concerning searching before sending - my apologies, but I really did
    try to search. For me, searching Xcode documentation for the phrase
    "toolbar popup" found nothing. Maybe my Xcode documentation is out of
    date? I also tried googling for "NSToolbar popup menu", but what I
    found were mostly  links to third-party open-source projects that
    didn't do what I needed.

    Best regards,
    Sergey Shapovalov.
  • On Oct 3, 2007, at 5:13 AM, Sergey Shapovalov wrote:

    > I'll definitely learn how this sample works. However, it does not
    > provide exactly what I need: a button in toolbar, from which a popup
    > menu will drop if the user clicks the button and holds it for a
    > while. In other words, what I need is exactly the same behavior as
    > implemented in Xcode windows. But I hope that having learned the
    > sample you have pointed to, I'll find a hint towards how to
    > implement what I need.
    >

    You're most of the way there

    you can find out how to insert a custom view using that example.  The
    custom view would display the image, and when it is clicked you can
    bring up the popup button relative to the button using using a context
    menu approach. see popUpContextMenu:withEvent:forView: for info about
    contextual menus

    I dont think you can achieve this without rolling that part
    yourself.  If you use popupbutton then you'll get a different look as
    I recall.

    > Concerning searching before sending - my apologies, but I really did
    > try to search. For me, searching Xcode documentation for the phrase
    > "toolbar popup" found nothing. Maybe my Xcode documentation is out
    > of date?

    That sample is ancient.. so it could be an issue of Xcode not
    indexing them with the version you have.
previous month october 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
29 30 31        
Go to today