From 4009a089e7da0e52cc81f3a0af4675aaaf4813f7 Mon Sep 17 00:00:00 2001 From: richard Date: Tue, 12 Oct 1999 12:59:10 +0000 Subject: [PATCH] Fixes from n.pero git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4989 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 ++++++++ Source/NSButton.m | 20 ++++++++++++++++++-- Source/NSCell.m | 18 +++++++++++++----- Source/NSView.m | 6 ++++-- 4 files changed, 43 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5ddc9a6c2..f616629a5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Oct 9 1999 Nicola Pero + + * Source/NSButton.m ([-keyDown:]): Perform a click if + the key is SPACE or ENTER. + * Source/NSCell.m ([-performClick:]): Completely rewritten. + * Source/NSView.m ([-previousValidKeyView]), + ([-nextValidKeyView]): fix to avoid an infinite loop. + 1999-10-09 * Model/GMAppKit.m ([NSPopUpButton -initWithModelUnarchiver:]): diff --git a/Source/NSButton.m b/Source/NSButton.m index 9f4c7b039..3152cac5d 100644 --- a/Source/NSButton.m +++ b/Source/NSButton.m @@ -294,8 +294,24 @@ id _nsbuttonCellClass = nil; - (void) keyDown: (NSEvent*)theEvent { - if ([self performKeyEquivalent: theEvent] == NO) - [super keyDown: theEvent]; + if ([self isEnabled]) + { + NSString *keyDescription = [theEvent charactersIgnoringModifiers]; + + // Handle SPACE or RETURN to perform a click + if (([keyDescription compare: @" "] == NSOrderedSame) + || ([theEvent keyCode] == 0x0d)) + { + [self performClick: self]; + return; + } + + // TODO: Understand better, I don't think this should be here. + if ([self performKeyEquivalent: theEvent] == YES) + return; + } + + [super keyDown: theEvent]; } // diff --git a/Source/NSCell.m b/Source/NSCell.m index b03263d6c..e0d3cedab 100644 --- a/Source/NSCell.m +++ b/Source/NSCell.m @@ -825,15 +825,26 @@ static Class cellClass; - (void) performClick: (id)sender { NSView *cv; + NSRect cvBounds; + NSWindow *cvWin; if (control_view) cv = control_view; else cv = [NSView focusView]; - NSLog(@"performClick:"); + cvBounds = [cv bounds]; + cvWin = [cv window]; + + [self highlight: YES withFrame: cvBounds inView: cv]; + [cvWin flushWindow]; + // Wait approx 1/5 seconds + [[NSRunLoop currentRunLoop] + runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.2]]; + + [self highlight: NO withFrame: cvBounds inView: cv]; + [cvWin flushWindow]; - [self highlight: YES withFrame: [cv frame] inView: cv]; if ([self action]) { NS_DURING @@ -842,14 +853,11 @@ static Class cellClass; } NS_HANDLER { - [self highlight: NO withFrame: [cv frame] inView: cv]; [localException raise]; } NS_ENDHANDLER } - [self highlight: NO withFrame: [cv frame] inView: cv]; } - /* * Assigning a Tag */ diff --git a/Source/NSView.m b/Source/NSView.m index 99313a9a3..3d26367ab 100644 --- a/Source/NSView.m +++ b/Source/NSView.m @@ -2090,7 +2090,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) theView = _nextKeyView; while (1) { - if ([theView acceptsFirstResponder] || (theView == nil)) + if ([theView acceptsFirstResponder] || (theView == nil) + || (theView == self)) return theView; theView = [theView nextKeyView]; @@ -2122,7 +2123,8 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level) theView = _previousKeyView; while (1) { - if ([theView acceptsFirstResponder] || (theView == nil)) + if ([theView acceptsFirstResponder] || (theView == nil) + || (theView == self)) return theView; theView = [theView previousKeyView];