mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 09:21:22 +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
b91e0079e4
commit
61b91e6b57
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>
|
2002-09-21 18:54 Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSOutlineView.m corrected preprocessor error messages.
|
* Source/NSOutlineView.m corrected preprocessor error messages.
|
||||||
|
|
|
@ -339,6 +339,7 @@ enum {
|
||||||
/*
|
/*
|
||||||
* Aiding Event Handling
|
* Aiding Event Handling
|
||||||
*/
|
*/
|
||||||
|
-(BOOL) needsPanelToBecomeKey;
|
||||||
- (void) setNextKeyView: (NSView*)aView;
|
- (void) setNextKeyView: (NSView*)aView;
|
||||||
- (NSView*) nextKeyView;
|
- (NSView*) nextKeyView;
|
||||||
- (NSView*) nextValidKeyView;
|
- (NSView*) nextValidKeyView;
|
||||||
|
|
|
@ -52,6 +52,8 @@
|
||||||
|
|
||||||
#include <AppKit/GMArchiver.h>
|
#include <AppKit/GMArchiver.h>
|
||||||
|
|
||||||
|
#include <AppKit/NSHelpManager.h>
|
||||||
|
|
||||||
#ifdef ALERT_TITLE
|
#ifdef ALERT_TITLE
|
||||||
static NSString *defaultTitle = @"Alert";
|
static NSString *defaultTitle = @"Alert";
|
||||||
#else
|
#else
|
||||||
|
@ -94,8 +96,6 @@ static NSString *defaultTitle = @" ";
|
||||||
|
|
||||||
- (BOOL) canBecomeKeyWindow
|
- (BOOL) canBecomeKeyWindow
|
||||||
{
|
{
|
||||||
if (_becomesKeyOnlyIfNeeded)
|
|
||||||
return NO;
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,6 +191,69 @@ static NSString *defaultTitle = @" ";
|
||||||
return self;
|
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 */
|
@end /* NSPanel */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -630,6 +630,11 @@ static Class concrete;
|
||||||
* NSView
|
* NSView
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
-(BOOL) needsPanelToBecomeKey
|
||||||
|
{
|
||||||
|
return _tf.is_editable;
|
||||||
|
}
|
||||||
|
|
||||||
/* text lays out from top to bottom */
|
/* text lays out from top to bottom */
|
||||||
- (BOOL) isFlipped
|
- (BOOL) isFlipped
|
||||||
{
|
{
|
||||||
|
|
|
@ -325,6 +325,11 @@ static Class textFieldCellClass;
|
||||||
return [self isSelectable];
|
return [self isSelectable];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL) needsPanelToBecomeKey
|
||||||
|
{
|
||||||
|
return [self isEditable];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) abortEditing
|
- (BOOL) abortEditing
|
||||||
{
|
{
|
||||||
if (_text_object)
|
if (_text_object)
|
||||||
|
|
|
@ -2430,6 +2430,11 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-(BOOL) needsPanelToBecomeKey
|
||||||
|
{
|
||||||
|
return NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) setNextKeyView: (NSView *)aView
|
- (void) setNextKeyView: (NSView *)aView
|
||||||
{
|
{
|
||||||
if (!aView)
|
if (!aView)
|
||||||
|
@ -3518,5 +3523,6 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -2742,6 +2742,9 @@ resetCursorRectsForView(NSView *theView)
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case NSLeftMouseDown:
|
case NSLeftMouseDown:
|
||||||
|
/*
|
||||||
|
Code shared with [NSPanel -sendEvent:], remember to update both places.
|
||||||
|
*/
|
||||||
{
|
{
|
||||||
BOOL wasKey = _f.is_key;
|
BOOL wasKey = _f.is_key;
|
||||||
|
|
||||||
|
@ -2751,11 +2754,11 @@ resetCursorRectsForView(NSView *theView)
|
||||||
}
|
}
|
||||||
if (_f.has_closed == NO)
|
if (_f.has_closed == NO)
|
||||||
{
|
{
|
||||||
|
v = [_contentView hitTest: [theEvent locationInWindow]];
|
||||||
if (_f.is_key == NO)
|
if (_f.is_key == NO)
|
||||||
{
|
{
|
||||||
[self makeKeyAndOrderFront: self];
|
[self makeKeyAndOrderFront: self];
|
||||||
}
|
}
|
||||||
v = [_contentView hitTest: [theEvent locationInWindow]];
|
|
||||||
if (_firstResponder != v)
|
if (_firstResponder != v)
|
||||||
{
|
{
|
||||||
[self makeFirstResponder: v];
|
[self makeFirstResponder: v];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue