Rewritten part of performClick: to avoid various problems (crashing

included) when there is no control view.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@5030 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
nico 1999-10-18 22:50:40 +00:00
parent be81d56e2e
commit ca0920e81a

View file

@ -824,32 +824,28 @@ static Class cellClass;
- (void) performClick: (id)sender
{
NSView *cv;
NSRect cvBounds;
NSWindow *cvWin;
SEL action = [self action];
if (control_view)
cv = control_view;
else
cv = [NSView focusView];
{
NSRect cvBounds = [control_view bounds];
NSWindow *cvWin = [control_view window];
cvBounds = [cv bounds];
cvWin = [cv window];
[self highlight: YES withFrame: cvBounds inView: cv];
[self highlight: YES withFrame: cvBounds inView: control_view];
[cvWin flushWindow];
// Wait approx 1/5 seconds
// Wait approx 1/10 seconds
[[NSRunLoop currentRunLoop]
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.2]];
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
[self highlight: NO withFrame: cvBounds inView: cv];
[self highlight: NO withFrame: cvBounds inView: control_view];
[cvWin flushWindow];
if ([self action])
if (action)
{
NS_DURING
{
[(NSControl*)cv sendAction: [self action] to: [self target]];
[(NSControl *)control_view sendAction: action to: [self target]];
}
NS_HANDLER
{
@ -858,6 +854,24 @@ static Class cellClass;
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
}
}
}
/*
* Assigning a Tag
*/