Adding a simple way to set a function for the target/action

This commit is contained in:
Ross Boucher committed 2009-11-17 09:28:44 -08:00
1 parent d041c69e0d
commit 11e6ad2153
2 files changed
+17 -2

No files matched your search

+15
View File
@@ -103,6 +103,7 @@ var CPControlBlackColor = [CPColor blackColor];
CGPoint _previousTrackingLocation;
CPString _toolTip;
Function _actionFunction;
}
+ (CPDictionary)themeAttributes
@@ -151,6 +152,7 @@ var CPControlBlackColor = [CPColor blackColor];
- (void)setAction:(SEL)anAction
{
_action = anAction;
_actionFunction = nil;
}
/*!
@@ -178,6 +180,19 @@ var CPControlBlackColor = [CPColor blackColor];
return _target;
}
- (void)setActionFunction:(Function)aFunction
{
[self setTarget:self];
[self setAction:@selector(performActionFunction:)];
_actionFunction = aFunction;
}
- (void)performActionFunction:(Object)sender
{
if (_actionFunction)
_actionFunction(sender);
}
/*!
Causes \c anAction to be sent to \c anObject.
@param anAction the action to send
+2 -2
View File
@@ -163,7 +163,7 @@
Returns the window this object controls.
*/
- (CPWindow)window
{
{
if (!_window)
{
[self windowWillLoad];
@@ -181,7 +181,7 @@
[CPException raise:CPInternalInconsistencyException reason:reason];
}
[self windowDidLoad];
[_document windowControllerDidLoadCib:self];