2001-12-17 16:51:51 +00:00
|
|
|
/** <title>NSResponder</title>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
<abstract>Abstract class which is basis of command and event processing</abstract>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
Copyright (C) 1996,1999 Free Software Foundation, Inc.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2001-12-17 16:51:51 +00:00
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
1996-05-30 20:03:15 +00:00
|
|
|
Date: 1996
|
|
|
|
|
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
2007-10-29 21:16:17 +00:00
|
|
|
modify it under the terms of the GNU Lesser General Public
|
1996-05-30 20:03:15 +00:00
|
|
|
License as published by the Free Software Foundation; either
|
2008-06-10 04:01:49 +00:00
|
|
|
version 2 of the License, or (at your option) any later version.
|
2007-10-29 21:16:17 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2007-10-29 21:16:17 +00:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
1996-05-30 20:03:15 +00:00
|
|
|
|
2007-10-29 21:16:17 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
2007-10-29 21:16:17 +00:00
|
|
|
If not, see <http://www.gnu.org/licenses/> or write to the
|
|
|
|
Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
|
|
|
Boston, MA 02110-1301, USA.
|
1996-05-30 20:03:15 +00:00
|
|
|
*/
|
|
|
|
|
2003-07-31 23:52:10 +00:00
|
|
|
#include "config.h"
|
2011-03-04 11:33:22 +00:00
|
|
|
#import <Foundation/NSCoder.h>
|
|
|
|
#import <Foundation/NSDebug.h>
|
|
|
|
#import <Foundation/NSInvocation.h>
|
|
|
|
#import "AppKit/NSResponder.h"
|
|
|
|
#import "AppKit/NSApplication.h"
|
|
|
|
#import "AppKit/NSMenu.h"
|
|
|
|
#import "AppKit/NSEvent.h"
|
|
|
|
#import "AppKit/NSGraphics.h"
|
|
|
|
#import "AppKit/NSHelpManager.h"
|
|
|
|
#import "AppKit/NSInputManager.h"
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
@implementation NSResponder
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
/*
|
|
|
|
* Class methods
|
|
|
|
*/
|
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
if (self == [NSResponder class])
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
[self setVersion: 1];
|
2001-12-18 00:30:21 +00:00
|
|
|
|
|
|
|
/* Gets the current input manager - this forces it to read the
|
|
|
|
key binding files at this stage. */
|
|
|
|
[NSInputManager currentInputManager];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
/*
|
|
|
|
* Instance methods
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* Managing the next responder
|
|
|
|
*/
|
2005-10-19 23:54:22 +00:00
|
|
|
- (NSResponder*) nextResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
return _next_responder;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (void) setNextResponder: (NSResponder*)aResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
_next_responder = aResponder;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2002-10-21 13:03:23 +00:00
|
|
|
/**
|
|
|
|
* Returns YES if the receiver is able to become the first responder,
|
|
|
|
* NO otherwise.
|
1999-05-04 13:17:26 +00:00
|
|
|
*/
|
|
|
|
- (BOOL) acceptsFirstResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (BOOL) becomeFirstResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (BOOL) resignFirstResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
/*
|
|
|
|
* Aid event processing
|
|
|
|
*/
|
2000-03-16 15:45:19 +00:00
|
|
|
- (BOOL) performKeyEquivalent: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2003-07-26 06:27:50 +00:00
|
|
|
/**
|
|
|
|
* If the receiver responds to anAction, it performs that method with
|
|
|
|
* anObject as its argument, discards any return value, and return YES.<br />
|
|
|
|
* Otherwise, the next responder in the chain is asked to perform
|
|
|
|
* anAction and the result of that is returned.<br />
|
|
|
|
* If no responder in the chain is able to respond to anAction, then
|
|
|
|
* NO is returned.
|
|
|
|
*/
|
1999-05-04 13:17:26 +00:00
|
|
|
- (BOOL) tryToPerform: (SEL)anAction with: (id)anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
/* Can we perform the action -then do it */
|
|
|
|
if ([self respondsToSelector: anAction])
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2009-11-23 23:06:00 +00:00
|
|
|
IMP actionIMP = [self methodForSelector: anAction];
|
|
|
|
if (0 != actionIMP)
|
|
|
|
{
|
|
|
|
actionIMP(self, anAction, anObject);
|
|
|
|
return YES;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
/* If we cannot perform then try the next responder */
|
2000-03-19 07:33:26 +00:00
|
|
|
if (!_next_responder)
|
1996-05-30 20:03:15 +00:00
|
|
|
return NO;
|
|
|
|
else
|
2000-03-19 07:33:26 +00:00
|
|
|
return [_next_responder tryToPerform: anAction with: anObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (BOOL) performMnemonic: (NSString*)aString
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) interpretKeyEvents:(NSArray*)eventArray
|
|
|
|
{
|
2001-12-18 00:30:21 +00:00
|
|
|
[[NSInputManager currentInputManager] handleKeyboardEvents: eventArray
|
|
|
|
client: self];
|
2000-03-16 15:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) flushBufferedKeyEvents
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) doCommandBySelector:(SEL)aSelector
|
|
|
|
{
|
|
|
|
if (![self tryToPerform: aSelector with: nil])
|
2002-02-27 21:04:37 +00:00
|
|
|
{
|
|
|
|
NSBeep();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-01-21 21:43 Alexander Malmberg <alexander@malmberg.org>
Various whitespace cleanups, comment type fixes, and changes
to avoid warnings from recent versions of gcc.
* Headers/Additions/GNUstepGUI/GSToolbar.h (-_toolbars): Declare.
* Source/NSWindow+Toolbar.m: Remove conflicting declaration of
[NSToolbar -_toolbars].
* Headers/Additions/GNUstepGUI/GSServicesManager.h,
Source/GSServicesMananger.m (-item2title:, -validateMenuItem:):
Adjust argument types.
* Headers/AppKit/NSMenu.h (-validateMenuItem:): Adjust argument
type.
* Source/NSTextView.m (-sizeToFit): Don't use size uninitialized
if neither resizable flags is set.
(-insertText:): Adjust argument type.
* Headers/AppKit/NSResponder.h, Source/NSResponder.m (-insertText:):
Adjust argument type. Document.
* Headers/AppKit/NSView.h: Change type of ivar _window to NSWindow *.
* Source/GSTitleView.m (-mouseDown:): Always initialize
startWindowOrigin.
* Source/NSApplication.m (-setApplicationIconImage:): Add casts
to avoid warnings.
* Source/NSCell.m (-cellSize): Add default: case.
* Source/NSPasteboard.m
([GSFiltered -pasteboard:provideDataForType:]): Detect and warn if we
can't find a filter that will get us the desired type.
* Source/NSProgressIndicator.m: Comment out unused variable 'images'.
* Source/NSBezierPath.m: Declare GSBezierPath fully before using it.
(-bezierPathByFlatteningPath, -bezierPathByReversingPath): Make sure
variables are always initialized.
* Source/NSMenuView.m,
* Source/NSPrintOperation.m,
* Source/NSSplitView.m,
* Source/NSTableHeaderView.m: Make sure variables are always
initialized.
* Source/NSBox.m,
* Source/NSImageview.m,
* Source/NSText.m,
* Source/NSTextStorage.m: Add missing includes.
* Source/GSKeyBindingTable.m,
* Source/GSLayoutManager.m,
* Source/NSBitmapImageRep+PNM.m,
* Source/NSBundleAdditions.m,
* Source/NSLayoutManager.m,
* Source/nsimage-tiff.h,
* Source/tiff.m,
* Headers/Additions/GNUstepGUI/GSDisplayServer.h,
* Source/GSDisplayServer.m: Change signedness of various variables.
* Source/NSPanel.m (-sendEvent:): Remove.
* Source/NSWindow.m (-becomesKeyOnlyIfNeeded): New method.
(-_sendEvent:becomesKeyOnlyIfNeeded:): Remove. Move code ...
(-sendEvent:): ... here. Use -becomesKeyOnlyIfNeeded instead
of the argument.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20590 72102866-910b-0410-8b05-ffd578937521
2005-01-21 20:39:18 +00:00
|
|
|
- (void) insertText: (id)aString
|
2002-02-27 21:04:37 +00:00
|
|
|
{
|
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder insertText: aString];
|
2002-02-27 21:04:37 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
NSBeep ();
|
|
|
|
}
|
2000-03-16 15:45:19 +00:00
|
|
|
}
|
|
|
|
|
2002-02-27 21:04:37 +00:00
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
/*
|
|
|
|
* Forwarding event messages
|
|
|
|
*/
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) flagsChanged: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder flagsChanged: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(flagsChanged:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) helpRequested: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2006-10-02 08:42:04 +00:00
|
|
|
if ([[NSHelpManager sharedHelpManager]
|
|
|
|
showContextHelpForObject: self
|
|
|
|
locationHint: [theEvent locationInWindow]] == NO)
|
|
|
|
{
|
|
|
|
if (_next_responder)
|
|
|
|
{
|
|
|
|
[_next_responder helpRequested: theEvent];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
1999-09-11 23:43:17 +00:00
|
|
|
[NSHelpManager setContextHelpModeActive: NO];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) keyDown: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder keyDown: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(keyDown:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) keyUp: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder keyUp: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(keyUp:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
- (void) otherMouseDown: (NSEvent*)theEvent
|
2000-08-03 08:48:22 +00:00
|
|
|
{
|
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder otherMouseDown: theEvent];
|
2000-08-03 08:48:22 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(otherMouseDown:)];
|
2000-08-03 08:48:22 +00:00
|
|
|
}
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
- (void) otherMouseDragged: (NSEvent*)theEvent
|
2000-08-03 08:48:22 +00:00
|
|
|
{
|
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder otherMouseDragged: theEvent];
|
2000-08-03 08:48:22 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(otherMouseDragged:)];
|
2000-08-03 08:48:22 +00:00
|
|
|
}
|
|
|
|
|
2002-03-02 07:23:18 +00:00
|
|
|
- (void) otherMouseUp: (NSEvent*)theEvent
|
2000-08-03 08:48:22 +00:00
|
|
|
{
|
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder otherMouseUp: theEvent];
|
2000-08-03 08:48:22 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(otherMouseUp:)];
|
2000-08-03 08:48:22 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder mouseDown: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(mouseDown:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) mouseDragged: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder mouseDragged: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(mouseDragged:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) mouseEntered: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder mouseEntered: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(mouseEntered:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) mouseExited: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder mouseExited: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(mouseExited:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) mouseMoved: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder mouseMoved: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(mouseMoved:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) mouseUp: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder mouseUp: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(mouseUp:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (void) noResponderFor: (SEL)eventSelector
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-05-04 13:17:26 +00:00
|
|
|
/* Only beep for key down events */
|
2010-09-09 23:50:38 +00:00
|
|
|
if (sel_isEqual(eventSelector, @selector(keyDown:)))
|
1998-12-16 15:21:55 +00:00
|
|
|
NSBeep();
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) rightMouseDown: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder != nil)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder rightMouseDown: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(rightMouseDown:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) rightMouseDragged: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder rightMouseDragged: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(rightMouseDragged:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (void) rightMouseUp: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder rightMouseUp: theEvent];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(rightMouseUp:)];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
2001-08-21 23:22:51 +00:00
|
|
|
- (void) scrollWheel: (NSEvent *)theEvent
|
|
|
|
{
|
2002-02-28 21:45:38 +00:00
|
|
|
if (_next_responder)
|
2003-08-20 12:13:34 +00:00
|
|
|
[_next_responder scrollWheel: theEvent];
|
2002-02-28 21:45:38 +00:00
|
|
|
else
|
2003-08-20 12:13:34 +00:00
|
|
|
[self noResponderFor: @selector(scrollWheel:)];
|
2001-08-21 23:22:51 +00:00
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
/*
|
|
|
|
* Services menu support
|
|
|
|
*/
|
2000-03-16 15:45:19 +00:00
|
|
|
- (id) validRequestorForSendType: (NSString*)typeSent
|
|
|
|
returnType: (NSString*)typeReturned
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
if (_next_responder)
|
|
|
|
return [_next_responder validRequestorForSendType: typeSent
|
1999-05-04 13:17:26 +00:00
|
|
|
returnType: typeReturned];
|
1996-05-30 20:03:15 +00:00
|
|
|
else
|
|
|
|
return nil;
|
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
/*
|
|
|
|
* NSCoding protocol
|
2000-03-19 07:33:26 +00:00
|
|
|
* NB. Don't encode responder chain - it's transient information that should
|
|
|
|
* be reconstructed from else where in the encoded archive.
|
1999-05-04 13:17:26 +00:00
|
|
|
*/
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([aCoder allowsKeyedCoding])
|
2004-10-18 01:48:15 +00:00
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if (_interface_style != NSNoInterfaceStyle)
|
2004-10-18 01:48:15 +00:00
|
|
|
{
|
|
|
|
[aCoder encodeInt: _interface_style
|
|
|
|
forKey: @"NSInterfaceStyle"];
|
|
|
|
}
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([self menu] != nil)
|
2004-10-18 01:48:15 +00:00
|
|
|
{
|
|
|
|
[aCoder encodeObject: [self menu]
|
|
|
|
forKey: @"NSMenu"];
|
|
|
|
}
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([self nextResponder] != nil)
|
2005-05-20 12:31:42 +00:00
|
|
|
{
|
|
|
|
[aCoder encodeConditionalObject: [self nextResponder]
|
|
|
|
forKey: @"NSNextResponder"];
|
|
|
|
}
|
2004-10-18 01:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-27 11:57:04 +00:00
|
|
|
[aCoder encodeValueOfObjCType: @encode(int) at: &_interface_style];
|
2004-10-18 01:48:15 +00:00
|
|
|
[aCoder encodeObject: _menu];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
2004-10-21 21:01:36 +00:00
|
|
|
id obj = nil;
|
2000-03-19 07:33:26 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([aDecoder allowsKeyedCoding])
|
2004-10-18 01:48:15 +00:00
|
|
|
{
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"NSInterfaceStyle"])
|
2004-10-18 01:48:15 +00:00
|
|
|
{
|
|
|
|
_interface_style = [aDecoder decodeIntForKey: @"NSInterfaceStyle"];
|
|
|
|
}
|
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"NSMenu"])
|
2004-10-18 01:48:15 +00:00
|
|
|
{
|
|
|
|
obj = [aDecoder decodeObjectForKey: @"NSMenu"];
|
|
|
|
}
|
2005-05-20 12:31:42 +00:00
|
|
|
|
2005-11-16 11:34:25 +00:00
|
|
|
if ([aDecoder containsValueForKey: @"NSNextResponder"])
|
2005-05-20 12:31:42 +00:00
|
|
|
{
|
|
|
|
[self setNextResponder: [aDecoder decodeObjectForKey: @"NSNextResponder"]];
|
|
|
|
}
|
2004-10-18 01:48:15 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-12-27 11:57:04 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(int) at: &_interface_style];
|
2004-10-18 01:48:15 +00:00
|
|
|
obj = [aDecoder decodeObject];
|
|
|
|
}
|
|
|
|
|
2000-03-19 07:33:26 +00:00
|
|
|
[self setMenu: obj];
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
return self;
|
|
|
|
}
|
2003-07-22 15:23:12 +00:00
|
|
|
- (void) dealloc
|
|
|
|
{
|
|
|
|
RELEASE(_menu);
|
|
|
|
[super dealloc];
|
|
|
|
}
|
2000-03-16 15:45:19 +00:00
|
|
|
- (NSMenu*) menu
|
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
return _menu;
|
2000-03-16 15:45:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setMenu: (NSMenu*)aMenu
|
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
ASSIGN(_menu, aMenu);
|
2000-03-16 15:45:19 +00:00
|
|
|
}
|
|
|
|
|
1999-05-04 13:17:26 +00:00
|
|
|
- (NSInterfaceStyle) interfaceStyle
|
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
return _interface_style;
|
1999-05-04 13:17:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setInterfaceStyle: (NSInterfaceStyle)aStyle
|
|
|
|
{
|
2000-03-19 07:33:26 +00:00
|
|
|
_interface_style = aStyle;
|
1999-05-04 13:17:26 +00:00
|
|
|
}
|
|
|
|
|
2000-03-16 15:45:19 +00:00
|
|
|
- (NSUndoManager*) undoManager
|
|
|
|
{
|
2006-12-24 09:37:16 +00:00
|
|
|
if (_next_responder)
|
|
|
|
return [_next_responder undoManager];
|
|
|
|
else
|
|
|
|
return nil;
|
2000-03-16 15:45:19 +00:00
|
|
|
}
|
2005-05-20 12:31:42 +00:00
|
|
|
|
|
|
|
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2007-01-17 12:09:41 +00:00
|
|
|
- (BOOL)presentError:(NSError *)error
|
|
|
|
{
|
|
|
|
error = [self willPresentError: error];
|
|
|
|
|
|
|
|
if (_next_responder)
|
|
|
|
{
|
|
|
|
return [_next_responder presentError: error];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return [NSApp presentError: error];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)presentError:(NSError *)error
|
|
|
|
modalForWindow:(NSWindow *)window
|
|
|
|
delegate:(id)delegate
|
|
|
|
didPresentSelector:(SEL)sel
|
|
|
|
contextInfo:(void *)context
|
|
|
|
{
|
|
|
|
error = [self willPresentError: error];
|
|
|
|
if (_next_responder)
|
|
|
|
{
|
|
|
|
[_next_responder presentError: error
|
|
|
|
modalForWindow: window
|
|
|
|
delegate: delegate
|
|
|
|
didPresentSelector: sel
|
|
|
|
contextInfo: context];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
[NSApp presentError: error
|
|
|
|
modalForWindow: window
|
|
|
|
delegate: delegate
|
|
|
|
didPresentSelector: sel
|
|
|
|
contextInfo: context];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSError *) willPresentError: (NSError *)error
|
|
|
|
{
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
@end
|