Giter Club home page Giter Club logo

nsalert-popover's Introduction

NSAlert+Popover

This category adds methods to open the alert within a NSPopover below any kind of NSView. The alerts do not run as modal windows, that is, your app continues execution while the alert's result will be processed in a execution block.

NSAlert+Popover Preview

Usage

Create a NSAlert and call runAsPopoverForView:withCompletionBlock:;:

NSAlert *alert = [NSAlert alertWithMessageText:@"Do you really want to delete this item?"
									 defaultButton:@"Delete"
								   alternateButton:@"Learn more"
									   otherButton:@"Cancel"
						 informativeTextWithFormat:@"Deleting this item will erase all associated data in the database. Click learn more if you need additional information."];
					 
[alert runAsPopoverForView:self.showNextDateButton withCompletionBlock:^(NSInteger *result) {
	// handle result
}];

Requirements

NSPopovers require at least OS X 10.7 (OS X Lion). This category has been built for and tested with ARC enabled only!

Contact

License

Copyright (c) 2013 Raffael Hannemann Under BSD License.

Want more?

Follow @raffael_me for similar releases.

nsalert-popover's People

Contributors

raffael avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nsalert-popover's Issues

`runAsPopoverForView:preferredEdge:withCompletionBlock:` ignores input `preferredEdge`

Variable preferredEdge is not used in runAsPopoverForView:preferredEdge:withCompletionBlock:, since it calls showRelativeToRect:ofView:preferredEdge: with hardcoded value NSMaxYEdge:

[popover showRelativeToRect:view.bounds ofView:view preferredEdge:NSMaxYEdge];

This line should be changed to use input parameterpreferredEdge as input:

[popover showRelativeToRect:view.bounds ofView:view preferredEdge:preferredEdge];

[NSAlert runAsPopoverForView:withCompletionBlock:] unrecognized selector sent to instance

Hi. I just want to try your code. I create default project, add button to window and add action

import "AppDelegate.h"

import "NSAlert+Popover.h"

@implementation AppDelegate

  • (IBAction)showBubble:(id)sender {

    NSAlert *alert = [NSAlert alertWithMessageText:@"Do you really want to delete this item?"
    defaultButton:@"Delete"
    alternateButton:@"Learn more"
    otherButton:@"Cancel"
    informativeTextWithFormat:@"Deleting this item will erase all associated data in the database. Click learn more if you need additional information."];

    [alert runAsPopoverForView:_window.contentView
    withCompletionBlock:^(NSInteger *result) {
    // handle result
    }];
    }
    @EnD

what I do wrong? Can you give the demo project?

Crash when clicking button

This is a crash report I received from a tester, I'm unable to reproduce it myself but it was on 10.9

Crashed Thread:  0  Dispatch queue: com.apple.main-thread

Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: EXC_I386_GPFLT

Application Specific Information:
objc_msgSend() selector name: checkForPreviouslyShownAlerts
Performing @selector(stopSynchronousPopoverAlert:) from sender NSButton 0x6100001529b0

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   libobjc.A.dylib                 0x00007fff86a8f097 objc_msgSend + 23
1   com.simplexo.SearchYourCloud    0x0000000108073615 0x10803d000 + 222741
2   com.apple.AppKit                0x00007fff8ef5a3d0 -[NSApplication sendAction:to:from:] + 327
3   com.apple.AppKit                0x00007fff8ef5a24e -[NSControl sendAction:to:] + 86
4   com.apple.AppKit                0x00007fff8efa6d7d -[NSCell _sendActionFrom:] + 128
5   com.apple.AppKit                0x00007fff8efc0715 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2316
6   com.apple.AppKit                0x00007fff8efbfae7 -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 487
7   com.apple.AppKit                0x00007fff8efbf1fd -[NSControl mouseDown:] + 706
8   com.apple.AppKit                0x00007fff8ef40d08 -[NSWindow sendEvent:] + 11296
9   com.apple.AppKit                0x00007fff8eedf744 -[NSApplication sendEvent:] + 2021
10  com.apple.AppKit                0x00007fff8ed2fa29 -[NSApplication run] + 646
11  com.apple.AppKit                0x00007fff8ed1a803 NSApplicationMain + 940
12  com.simplexo.SearchYourCloud    0x000000010803e704 0x10803d000 + 5892

It appears that the NSAlert is being dereferenced before [self checkForPreviouslyShownAlerts]?

Here is my code, I may put the alert into an iVar to see if it rectifies my user's issue.

NSAlert *noSourcesAlert = [NSAlert alertWithMessageText:NSLocalizedString(@"Title", nil)
                                                      defaultButton:NSLocalizedString(@"Yes", nil)
                                                    alternateButton:NSLocalizedString(@"No", nil)
                                                        otherButton:nil
                                          informativeTextWithFormat:NSLocalizedString(@"Would you like to add your first remote cloud source?", nil)];
            [noSourcesAlert setAlertStyle:NSInformationalAlertStyle];
            [noSourcesAlert runAsPopoverForView:self.searchField preferredEdge:NSMaxYEdge withCompletionBlock:^(NSInteger result) {
                switch (result) {
                    case NSAlertFirstButtonReturn:
                        [self executeMethod];
                        break;
                    case NSAlertSecondButtonReturn:
                    default:
                        break;
                }
            }];

In Swift: The view isn't dismissed when button clicked

Hi, I don't know if you're still working on this extension but I hope you'll have a look at my problem:
I used this code:

var alert = NSAlert()
                    alert.alertStyle = .WarningAlertStyle
                    alert.messageText = "Error!"
                    alert.runAsPopoverForView(tfInput, withCompletionBlock: {
                        (result : Int) in
                            println("Result: \(result)")
                        }
                        )

tfInput is a NSTextField inside a NSWindow. When I clicked the OK button, the alert view isn't dismissed and the program doesn't jump into the completion block.

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.