Cocoa custom view for NSMenuItem

I am developing a small application that displays active menu mounts in NSStatusBar. So far it looks like this: alt text http://www.freeimagehosting.net/uploads/9ab690d5eb.png

I want to add an extract button to the right of each menu item (for example, the left pane in Finder). I know that I need to create my own view and set it using the setView: method. The problem is that I am very new to Cocoa, and right now I donโ€™t know how to dive into the theme of user view. Actually, I programmed a lot, but still haven't worked with interfaces :). Do any of you have a good tutorial for adding a custom view to NSMenuItem?

I think this application will be very convenient because you can hide the installed icons from the desktop. The problem is that you always need to go back to the search to disconnect the volume ...

Thanks for any help or advice you have!

+6
cocoa nsview nsmenuitem
source share
1 answer

This is an optional view. It could just be a standard NSView that acts as a container for standard controls.

The intricate part of a beginner makes viewing reusable. You will need your own subclass of NSViewController with the appropriate nib / xib view (configured using the name label and extract button). For each menu item, you create a new NSViewController using XIB (-initWithNibName: bundle :) and set its present object to the mount point. A subclass of your controller will have everything that it needs to respond to pressing the eject button, set the label to its path to the object, etc.

+2
source share

All Articles