Adding HotKeys to ITKit... This is the new HotKey code by Quentin of
[ITKit.git] / ITHotKey.m
1 //
2 //  ITHotKey.m
3 //
4 //  Created by Quentin Carnicelli on Sat Aug 02 2003.
5 //  Copyright (c) 2003 iThink Software. All rights reserved.
6 //
7
8 #import "ITHotKey.h"
9
10 #import "ITHotKeyCenter.h"
11 #import "ITKeyCombo.h"
12
13 @implementation ITHotKey
14
15 - (id)init
16 {
17         self = [super init];
18         
19         if( self )
20         {
21                 [self setKeyCombo: [ITKeyCombo clearKeyCombo]];
22         }
23         
24         return self;
25 }
26
27 - (void)dealloc
28 {
29         [mName release];
30         [mKeyCombo release];
31         
32         [super dealloc];
33 }
34
35 - (NSString*)description
36 {
37         return [NSString stringWithFormat: @"<%@: %@>", NSStringFromClass( [self class] ), [self keyCombo]];
38 }
39
40 #pragma mark -
41
42 - (void)setKeyCombo: (ITKeyCombo*)combo
43 {
44         [combo retain];
45         [mKeyCombo release];
46         mKeyCombo = combo;
47 }
48
49 - (ITKeyCombo*)keyCombo
50 {
51         return mKeyCombo;
52 }
53
54 - (void)setName: (NSString*)name
55 {
56         [name retain];
57         [mName release];
58         mName = name;
59 }
60
61 - (NSString*)name
62 {
63         return mName;
64 }
65
66 - (void)setTarget: (id)target
67 {
68         mTarget = target;
69 }
70
71 - (id)target
72 {
73         return mTarget;
74 }
75
76 - (void)setAction: (SEL)action
77 {
78         mAction = action;
79 }
80
81 - (SEL)action
82 {
83         return mAction;
84 }
85
86 - (void)invoke
87 {
88         [mTarget performSelector: mAction withObject: self];
89 }
90
91 @end