diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index f9ddc817e..ca39efb1f 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -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 diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j index 09c71e624..8dacde4ae 100644 --- a/AppKit/CPWindowController.j +++ b/AppKit/CPWindowController.j @@ -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];