mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-07 17:38:02 +00:00
Adding a simple way to set a function for the target/action
This commit is contained in:
1 parent
d041c69e0d
commit
11e6ad2153
2 files changed
+17
-2
No files matched your search
@@ -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
|
||||
|
||||
@@ -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];
|
||||
|
||||
|
||||
Reference in new issue
Block a user