• This repository has been archived on 16/Sep/2019
  • Stars
    star
    222
  • Rank 179,123 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 10 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

CCNStatusItem is a subclass of NSObject to act as a custom view for NSStatusItem. It supports a customizable statusItemWindow handling any viewController for presenting the content.

Flattr this git repo Travis Status

Overview

CCNStatusItem is a subclass of NSObject to act as a custom NSStatusItem. Running on Yosemite it has full support for the class NSStatusBarButton which is provided by NSStatusItem via the button property.

Features:

  • Yosemite's dark menu mode will be automatically handled
  • Proximity drag detection
  • Support for Drag&Drop
  • Custom Views as StatusItems
  • Support for switching the StatusItem on/off (in case you're using both the StatusItem and a Dock Icon)

It supports a customizable statusItemWindow that will manage any NSViewController instance for presenting the content.

This screenshot presents the current example application:

CCNStatusItem Example Application

Integration

You can add CCNStatusItem by using CocoaPods. Just add this line to your Podfile:

pod 'CCNStatusItem'

Usage

After it's integrated into your project you are just a few lines of code away from your (maybe) first NSStatusItem with a custom view and a beautiful looking popover window. A good place to add these lines of code is your AppDelegate:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
   ...
    [[CCNStatusItem sharedInstance] presentStatusItemWithImage:[NSImage imageNamed:@"statusbar-icon"]
                                         contentViewController:[ContentViewController viewController]];
   ...
}

That's all! You will have some options to change the design of this statusItem popover window using CCNStatusItemWindowConfiguration. In the example above internally CCNStatusItem uses [CCNStatusItemWindowConfiguration defaultConfiguration] to set a default design and behavior of the status bar popover window. The next example will show you how to change this design and behaviour:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    ...
    
    // configure the status item
    CCNStatusItem *sharedItem = [CCNStatusItem sharedInstance];
    sharedItem.windowConfiguration.presentationTransition = CCNPresentationTransitionSlideAndFade;
    sharedItem.proximityDragDetectionHandler = ^(CCNStatusItem *item, NSPoint eventLocation, CCNStatusItemProximityDragStatus dragStatus) {
        switch (dragStatus) {
            case CCNProximityDragStatusEntered:
                [item showStatusItemWindow];
                break;

            case CCNProximityDragStatusExited:
                [item dismissStatusItemWindow];
                break;
        }
    };
    [sharedItem presentStatusItemWithImage:[NSImage imageNamed:@"statusbar-icon"]
                     contentViewController:[ContentViewController viewController]];
    ...
}

Some Side Notes

The statusItem popover's frame size will be determined automatically by calling preferedContentSize on the contentViewController. So you shouldn't forget to set it to a reasonable value. Using XIB's for building the content a good way to do so is returning:

- (CGSize)preferredContentSize {
    return self.view.frame.size;
}

Requirements

CCNStatusItem has been written using ARC and "modern" Objective-C 2. It supports OS X 10.10 Yosemite and above.

Contribution

The code is provided as-is, and it is far off being complete or free of bugs. If you like this component feel free to support it. Make changes related to your needs, extend it or just use it in your own project. Pull-Requests and Feedbacks are very welcome. Just contact me at [[email protected]](mailto:[email protected]?Subject=[CCNStatusItem] Your component on Github) or send me a ping on Twitter @TheCocoaNaut.

Documentation

The complete documentation you will find on CocoaDocs.

License

This software is published under the MIT License.

Software that uses CCNStatusItem

  • Review Times - A small Mac tool that shows you the calculated average of the review times for both the Mac App Store and the iOS App Store
  • SalesX - SalesX is the simplest way to reach your iTC sales reports

More Repositories

1

CNGridView

CNGridView is a (wanna be) replacement for NSCollectionView. It has full delegate and dataSource support with method calls like known from NSTableView/UITableView.
Objective-C
150
star
2

CNSplitView

CNSplitView is an feature enhanced derivative of NSSplitView. It has support for sticky top or bottom toolbars for each of its subviews.
Objective-C
120
star
3

CCNPreferencesWindowController

CCNPreferencesWindowController is an Objective-C subclass of NSWindowController that automatically manages your custom view controllers for handling app preferences.
Objective-C
108
star
4

CNUserNotification

CNUserNotification is a kind of proxy to give OS X Lion 10.7 β€žthe sameβ€Ÿ support for user notifications like OS X Mountain Lion 10.8 does. Benefits are also a bit more flexibility since you are able to define a custom banner image or variable dismiss delay times.
Objective-C
93
star
5

CCNNavigationController

An Mac OS X Navigation Controller that acts mostly like the counter part on iOS - UINavigationController.
Objective-C
61
star
6

CCNLaunchAtLoginItem

An Objective-C class that encapsulates the functionality for launching a Mac application automatic on login, presented in a very simple interface.
Objective-C
16
star
7

Cooking-Recipes

Lose Sammlung veganer Rezepte
14
star
8

Xcode-Coordinator-Template

An Xcode File Template that creates an Objective-C Coordinator class.
Shell
7
star
9

Xcode-CodeSnippets

A set of Xcode CodeSnippets I use
7
star
10

CCNXML

Simple basic handling of XML files for both reading and manual creation in Objective-C.
Objective-C
4
star
11

CCNTreeNode

An easy way to build a tree of nested objects.
Objective-C
3
star
12

RadioTimeKit

The Swift SDK for TuneIn
Swift
2
star
13

Xcode-File-Templates

Shell
1
star