Handle becomesKeyOnlyIfNeeded in NSPanel properly.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14508 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
alexm 2002-09-21 23:33:37 +00:00
parent 67baee0c6d
commit 61cc498161
7 changed files with 94 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2002-09-22 01:23 Alexander Malmberg <alexander@malmberg.org>
* Headers/gnustep/gui/NSView.h, Source/NSPanel.m, Source/NSText.m,
Source/NSTextField.m, Source/NSView.m, Source/NSWindow.m: Add
-needsPanelToBecomeKey method to NSView and override it to return
YES in NSText and NSTextField. Use it in NSPanel to handle
becomesKeyOnlyIfNeeded properly.
2002-09-21 18:54 Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSOutlineView.m corrected preprocessor error messages.

View file

@ -339,6 +339,7 @@ enum {
/*
* Aiding Event Handling
*/
-(BOOL) needsPanelToBecomeKey;
- (void) setNextKeyView: (NSView*)aView;
- (NSView*) nextKeyView;
- (NSView*) nextValidKeyView;

View file

@ -52,6 +52,8 @@
#include <AppKit/GMArchiver.h>
#include <AppKit/NSHelpManager.h>
#ifdef ALERT_TITLE
static NSString *defaultTitle = @"Alert";
#else
@ -94,8 +96,6 @@ static NSString *defaultTitle = @" ";
- (BOOL) canBecomeKeyWindow
{
if (_becomesKeyOnlyIfNeeded)
return NO;
return YES;
}
@ -191,6 +191,69 @@ static NSString *defaultTitle = @" ";
return self;
}
- (void) sendEvent: (NSEvent*)theEvent
{
/*
Code shared with [NSWindow -sendEvent:], remember to update both places.
*/
NSView *v;
NSEventType type;
type = [theEvent type];
switch (type)
{
case NSLeftMouseDown:
{
BOOL wasKey = _f.is_key;
if ([NSApp isActive] == NO && ((NSWindow *)self) != [NSApp iconWindow])
{
[NSApp activateIgnoringOtherApps: YES];
}
if (_f.has_closed == NO)
{
v = [_contentView hitTest: [theEvent locationInWindow]];
if (_f.is_key == NO)
{
if (!_becomesKeyOnlyIfNeeded || [v needsPanelToBecomeKey])
[self makeKeyAndOrderFront: self];
}
if (_firstResponder != v)
{
[self makeFirstResponder: v];
}
if (_lastDragView)
DESTROY(_lastDragView);
if (wasKey == YES || [v acceptsFirstMouse: theEvent] == YES)
{
if ([NSHelpManager isContextHelpModeActive])
{
[v helpRequested: theEvent];
}
else
{
/* Technically this should be just _lastView,
but I don't think it's a problem reusing this
ivar */
ASSIGN(_lastDragView, v);
[v mouseDown: theEvent];
}
}
else
{
[self mouseDown: theEvent];
}
}
_lastPoint = [theEvent locationInWindow];
break;
}
default:
[super sendEvent: theEvent];
break;
}
}
@end /* NSPanel */

View file

@ -630,6 +630,11 @@ static Class concrete;
* NSView
*/
-(BOOL) needsPanelToBecomeKey
{
return _tf.is_editable;
}
/* text lays out from top to bottom */
- (BOOL) isFlipped
{

View file

@ -325,6 +325,11 @@ static Class textFieldCellClass;
return [self isSelectable];
}
-(BOOL) needsPanelToBecomeKey
{
return [self isEditable];
}
- (BOOL) abortEditing
{
if (_text_object)

View file

@ -2430,6 +2430,11 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
return t;
}
-(BOOL) needsPanelToBecomeKey
{
return NO;
}
- (void) setNextKeyView: (NSView *)aView
{
if (!aView)
@ -3518,5 +3523,6 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
}
}
}
@end

View file

@ -2742,6 +2742,9 @@ resetCursorRectsForView(NSView *theView)
switch (type)
{
case NSLeftMouseDown:
/*
Code shared with [NSPanel -sendEvent:], remember to update both places.
*/
{
BOOL wasKey = _f.is_key;
@ -2751,11 +2754,11 @@ resetCursorRectsForView(NSView *theView)
}
if (_f.has_closed == NO)
{
v = [_contentView hitTest: [theEvent locationInWindow]];
if (_f.is_key == NO)
{
[self makeKeyAndOrderFront: self];
}
v = [_contentView hitTest: [theEvent locationInWindow]];
if (_firstResponder != v)
{
[self makeFirstResponder: v];