Add helper method for action sending.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@27773 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
fredkiefer 2009-02-03 22:49:22 +00:00
parent d5997b82fa
commit 1c046acbfc
2 changed files with 35 additions and 34 deletions

View file

@ -1,3 +1,8 @@
2009-02-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSCell.m (-_sendActionFrom:): New helper method for
action sending.
2009-02-03 Fred Kiefer <FredKiefer@gmx.de> 2009-02-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/GSNibLoading.m (NSButtonImageSource -initWithCoder:): Add * Source/GSNibLoading.m (NSButtonImageSource -initWithCoder:): Add

View file

@ -1367,6 +1367,31 @@ static NSColor *dtxtCol;
[self performClickWithFrame: [cv bounds] inView: cv]; [self performClickWithFrame: [cv bounds] inView: cv];
} }
/*
* Helper method used to send actions. Sender normally is [self controlView].
*/
- (BOOL) _sendActionFrom: (id)sender
{
SEL action = [self action];
if ([sender respondsTo: @selector(sendAction:to:)])
{
return [sender sendAction: action to: [self target]];
}
else
{
if (sender == nil)
sender = self;
if (action)
{
return [NSApp sendAction: action to: [self target] from: sender];
}
}
return NO;
}
/** /**
* Simulates a single click in the cell. * Simulates a single click in the cell.
* The display of the cell with this event * The display of the cell with this event
@ -1375,8 +1400,6 @@ static NSColor *dtxtCol;
*/ */
- (void) performClickWithFrame: (NSRect)cellFrame inView: (NSView *)controlView - (void) performClickWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{ {
SEL action = [self action];
if (_cell.is_disabled == YES) if (_cell.is_disabled == YES)
{ {
return; return;
@ -1399,34 +1422,9 @@ static NSColor *dtxtCol;
[self highlight: NO withFrame: cellFrame inView: controlView]; [self highlight: NO withFrame: cellFrame inView: controlView];
[cvWin flushWindow]; [cvWin flushWindow];
[controlView unlockFocus]; [controlView unlockFocus];
}
NS_DURING [self _sendActionFrom: controlView];
{
[(NSControl*)controlView sendAction: action to: [self target]];
}
NS_HANDLER
{
[localException raise];
}
NS_ENDHANDLER
}
else // We have no control view. The best we can do is the following.
{
if (action)
{
NS_DURING
{
[[NSApplication sharedApplication] sendAction: action
to: [self target]
from: self];
}
NS_HANDLER
{
[localException raise];
}
NS_ENDHANDLER
}
}
} }
/* /*
@ -1556,8 +1554,6 @@ static NSColor *dtxtCol;
NSPoint point = [controlView convertPoint: location fromView: nil]; NSPoint point = [controlView convertPoint: location fromView: nil];
float delay; float delay;
float interval; float interval;
id target = [self target];
SEL action = [self action];
NSPoint last_point = point; NSPoint last_point = point;
BOOL done; BOOL done;
BOOL mouseWentUp; BOOL mouseWentUp;
@ -1575,7 +1571,7 @@ static NSColor *dtxtCol;
if ((_action_mask & NSLeftMouseDownMask) if ((_action_mask & NSLeftMouseDownMask)
&& [theEvent type] == NSLeftMouseDown) && [theEvent type] == NSLeftMouseDown)
[(NSControl*)controlView sendAction: action to: target]; [self _sendActionFrom: controlView];
if (_action_mask & NSPeriodicMask) if (_action_mask & NSPeriodicMask)
{ {
@ -1667,7 +1663,7 @@ static NSColor *dtxtCol;
&& (_action_mask & NSLeftMouseDraggedMask)) && (_action_mask & NSLeftMouseDraggedMask))
|| ((eventType == NSPeriodic) || ((eventType == NSPeriodic)
&& (_action_mask & NSPeriodicMask)))) && (_action_mask & NSPeriodicMask))))
[(NSControl*)controlView sendAction: action to: target]; [self _sendActionFrom: controlView];
} }
if (!done) if (!done)
@ -1690,7 +1686,7 @@ static NSColor *dtxtCol;
{ {
[self setNextState]; [self setNextState];
if ((_action_mask & NSLeftMouseUpMask)) if ((_action_mask & NSLeftMouseUpMask))
[(NSControl*)controlView sendAction: action to: target]; [self _sendActionFrom: controlView];
} }
// Return YES only if the mouse went up within the cell // Return YES only if the mouse went up within the cell