-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathActionButton.m
executable file
·53 lines (38 loc) · 1.12 KB
/
ActionButton.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//
// ActionButton.m
// LabStatus
//
// Created by Christian Pape on 08.10.08.
// Copyright 2008 cc-productions. All rights reserved.
//
#import "ActionButton.h"
@implementation ActionButton
- (id)initWithFrame:(NSRect)frameRect
{
if (![super initWithFrame:frameRect])
return nil;
[self setImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"button-up" ofType:@"png"]]];
[self setAlternateImage:[[NSImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"button-down" ofType:@"png"]]];
[self setButtonType:NSMomentaryChangeButton];
[self setTitle:@""];
[self setBordered:NO];
return self;
}
- (void)setCommand:(NSString*)aCommand
{
// NSLog(aCommand);
command = aCommand;
[self setTarget: self];
[self setAction: @selector(invokeAction:)];
}
- (IBAction)invokeAction:(id)sender
{
// NSLog(command);
// execute task
NSTask *task = [[NSTask alloc] init];
[task setLaunchPath:@"/bin/sh"];
NSArray *arguments = [NSArray arrayWithObjects: @"-c", command, nil];
[task setArguments: arguments];
[task launch];
}
@end