Code Monkey home page Code Monkey logo

kftoolbar's Introduction

#A Toolbar for NSWindows Travis Status

An easy to setup and use toolbar that can contain KFToolbarItems (what is actually a wrapper for NSButtons).

<Display Name>

Installation

KFAboutWindow is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "KFToolbar"

##Usage Actions are handled inside a block. An exhaustive example is included.

KFToolbarItem *addItem = [KFToolbarItem toolbarItemWithType:NSToggleButton icon:[NSImage imageNamed:NSImageNameAddTemplate] tag:0];
addItem.toolTip = @"Add";
addItem.keyEquivalent = @"q";

KFToolbarItem *removeItem = [KFToolbarItem toolbarItemWithIcon:[NSImage imageNamed:NSImageNameRemoveTemplate] tag:1];
removeItem.toolTip = @"Remove";

self.toolbar.leftItems = @[addItem, removeItem];
self.toolbar.rightItems = @[[KFToolbarItem toolbarItemWithIcon:[NSImage imageNamed:NSImageNameEnterFullScreenTemplate] tag:2], [KFToolbarItem toolbarItemWithIcon:[NSImage imageNamed:NSImageNameExitFullScreenTemplate] tag:3]];

[self.toolbar setItemSelectionHandler:^(KFToolbarItemSelectionType selectionType, KFToolbarItem *toolbarItem, NSUInteger tag)
{
    switch (tag)
    {
        case 0:
            break;
        
        case 1:
            addItem.enabled = !addItem.isEnabled;
            break;

        case 2:
        {
            [self setControlsEnabled:NO forView:self.toolbar.superview];
            double delayInSeconds = 2.0;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void)
            {
                [self setControlsEnabled:YES forView:self.toolbar.superview];
            });
            break;
        }
            
        case 3:
        {
            self.toolbar.enabled = NO;
            double delayInSeconds = 2.0;
            dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
            dispatch_after(popTime, dispatch_get_main_queue(), ^(void)
            {
                self.toolbar.enabled = YES;
            });
            break;
        }

        default:
            break;
    }
}];

Author

Rico Becker, @ricobeck

Contributors

Gunnar Herzog, @trispo
Markus Müller, @m_mlr

License

KFToolbar is available under the MIT license. See the LICENSE file for more info.

kftoolbar's People

Contributors

ricobeck avatar mmllr avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.