Created
August 7, 2015 03:58
-
-
Save abhibeckert/dbeae1ea7716e2f49506 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* example usage in Cocoa Script: | |
// create a window | |
var window = [[NSWindow alloc] init] | |
// create an OK button | |
var okButton = [[NSButton alloc] initWithFrame:NSMakeRect(10, 10, 100, 100)] | |
[okButton setTitle:"Continue"] | |
[okButton sizeToFit] | |
[okButton setKeyEquivalent:"\r"] | |
[[window contentView] addSubview:okButton] | |
//// put more stuff in the window here; text fields, etc //// | |
// show window, and wait for the OK button to be pressed | |
var okButtonTarget = [COTarget targetWithAction:function(sender) { | |
[window orderOut:nil]; | |
[NSApp stopModal]; | |
}] | |
[okButton setTarget:okButtonTarget] | |
[okButton setAction:"callAction:"] | |
// run modal | |
[NSApp runModalForWindow:window]; | |
*/ | |
#import <Foundation/Foundation.h> | |
#import "MOJavaScriptObject.h" | |
#import <CocoaScript/COScript.h> | |
@interface COTarget : NSObject | |
@property MOJavaScriptObject *action; | |
+ (instancetype)targetWithAction:(MOJavaScriptObject *)action; | |
- (instancetype)initWithAction:(MOJavaScriptObject *)action; | |
- (void)callAction:(id)sender; | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment