mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 19:00:47 +00:00
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:
parent
be81d56e2e
commit
ca0920e81a
1 changed files with 41 additions and 27 deletions
|
@ -824,38 +824,52 @@ static Class cellClass;
|
||||||
|
|
||||||
- (void) performClick: (id)sender
|
- (void) performClick: (id)sender
|
||||||
{
|
{
|
||||||
NSView *cv;
|
SEL action = [self action];
|
||||||
NSRect cvBounds;
|
|
||||||
NSWindow *cvWin;
|
|
||||||
|
|
||||||
if (control_view)
|
|
||||||
cv = control_view;
|
|
||||||
else
|
|
||||||
cv = [NSView focusView];
|
|
||||||
|
|
||||||
cvBounds = [cv bounds];
|
|
||||||
cvWin = [cv window];
|
|
||||||
|
|
||||||
[self highlight: YES withFrame: cvBounds inView: cv];
|
if (control_view)
|
||||||
[cvWin flushWindow];
|
{
|
||||||
// Wait approx 1/5 seconds
|
NSRect cvBounds = [control_view bounds];
|
||||||
[[NSRunLoop currentRunLoop]
|
NSWindow *cvWin = [control_view window];
|
||||||
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.2]];
|
|
||||||
|
|
||||||
[self highlight: NO withFrame: cvBounds inView: cv];
|
[self highlight: YES withFrame: cvBounds inView: control_view];
|
||||||
[cvWin flushWindow];
|
[cvWin flushWindow];
|
||||||
|
|
||||||
if ([self action])
|
// Wait approx 1/10 seconds
|
||||||
|
[[NSRunLoop currentRunLoop]
|
||||||
|
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
|
||||||
|
|
||||||
|
[self highlight: NO withFrame: cvBounds inView: control_view];
|
||||||
|
[cvWin flushWindow];
|
||||||
|
|
||||||
|
if (action)
|
||||||
|
{
|
||||||
|
NS_DURING
|
||||||
|
{
|
||||||
|
[(NSControl *)control_view 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.
|
||||||
{
|
{
|
||||||
NS_DURING
|
if (action)
|
||||||
{
|
{
|
||||||
[(NSControl*)cv sendAction: [self action] to: [self target]];
|
NS_DURING
|
||||||
}
|
{
|
||||||
NS_HANDLER
|
[[NSApplication sharedApplication] sendAction: action
|
||||||
{
|
to: [self target]
|
||||||
[localException raise];
|
from: self];
|
||||||
}
|
}
|
||||||
NS_ENDHANDLER
|
NS_HANDLER
|
||||||
|
{
|
||||||
|
[localException raise];
|
||||||
|
}
|
||||||
|
NS_ENDHANDLER
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue