mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-30 22:50:37 +00:00
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:
parent
67baee0c6d
commit
61cc498161
7 changed files with 94 additions and 3 deletions
|
@ -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.
|
||||
|
|
|
@ -339,6 +339,7 @@ enum {
|
|||
/*
|
||||
* Aiding Event Handling
|
||||
*/
|
||||
-(BOOL) needsPanelToBecomeKey;
|
||||
- (void) setNextKeyView: (NSView*)aView;
|
||||
- (NSView*) nextKeyView;
|
||||
- (NSView*) nextValidKeyView;
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
||||
|
|
|
@ -630,6 +630,11 @@ static Class concrete;
|
|||
* NSView
|
||||
*/
|
||||
|
||||
-(BOOL) needsPanelToBecomeKey
|
||||
{
|
||||
return _tf.is_editable;
|
||||
}
|
||||
|
||||
/* text lays out from top to bottom */
|
||||
- (BOOL) isFlipped
|
||||
{
|
||||
|
|
|
@ -325,6 +325,11 @@ static Class textFieldCellClass;
|
|||
return [self isSelectable];
|
||||
}
|
||||
|
||||
-(BOOL) needsPanelToBecomeKey
|
||||
{
|
||||
return [self isEditable];
|
||||
}
|
||||
|
||||
- (BOOL) abortEditing
|
||||
{
|
||||
if (_text_object)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue