Label Chooser Control
- MLLabelChooser 1.0.1 (5 Kb)
- Second version of the label chooser control. June 11, 2010.
Requires Snow Leopard
Cocoa offers no standard control to chose a color label for a file. Thus, each developer in the need for selecting a file color label need to build his own custom control to mimic the one found in the Finder, or use something else like a pop up button that leaves things less conformable for the user.
I’ve been confronted to this problem while writing Magic Launch, and I had to create my own label chooser control. I’m releasing it for free in the hope it might be useful to other developers like me who needs it but would like to avoid rewriting the wheel.
You can download and install Magic Launch if you want to see it at work.
How to Use
MLLabelChooser is a subclass of NSControl.
The control should to be sized at least 69×18. You can query its value with
intValue and set its value with
setIntValue. It does not support bindings (but that could easily be added).
labelText property can optionally be linked to a text field to display the name of the label under the mouse pointer. If you do this, you should add a localized string
“%@” (quotes included) to your Localizable.string file so that the label can be put inside localized quotes.
If you improve upon this control, please let me know so I can either incorporate your improvements or link to your improved version.
MLLabelChooser is available under the terms of the Boost Software License 1.0.
- Fix for a crash inside the call to function
-[NSWorkspace fileLabels]when the garbage collector is off. The workaround requires a potential memory leak though. rdar://8084710
- Initial release.