1999-04-01 06:22:28 +00:00
|
|
|
/*
|
1996-05-30 20:03:15 +00:00
|
|
|
NSTextField.m
|
|
|
|
|
|
|
|
Text field control class for text entry
|
|
|
|
|
|
|
|
Copyright (C) 1996 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
Author: Scott Christley <scottc@net-community.com>
|
|
|
|
Date: 1996
|
1998-11-25 17:16:48 +00:00
|
|
|
Author: Felipe A. Rodriguez <far@ix.netcom.com>
|
|
|
|
Date: August 1998
|
1999-04-01 06:22:28 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
This file is part of the GNUstep GUI Library.
|
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Library General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
1999-04-01 06:22:28 +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
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Library General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public
|
1996-10-18 17:14:13 +00:00
|
|
|
License along with this library; see the file COPYING.LIB.
|
|
|
|
If not, write to the Free Software Foundation,
|
|
|
|
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1999-04-01 06:22:28 +00:00
|
|
|
*/
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-09-23 22:43:24 +00:00
|
|
|
#include <gnustep/gui/config.h>
|
1998-11-25 17:16:48 +00:00
|
|
|
|
1997-08-18 17:10:23 +00:00
|
|
|
#include <Foundation/NSString.h>
|
1998-11-25 17:16:48 +00:00
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
#include <AppKit/NSTextField.h>
|
|
|
|
#include <AppKit/NSWindow.h>
|
|
|
|
#include <AppKit/NSTextFieldCell.h>
|
|
|
|
#include <AppKit/NSApplication.h>
|
1997-03-05 01:11:17 +00:00
|
|
|
#include <AppKit/NSCursor.h>
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
@implementation NSTextField
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// class variables
|
|
|
|
//
|
1998-12-16 11:48:33 +00:00
|
|
|
id _nsTextfieldCellClass = nil;
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-10-18 19:24:45 +00:00
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
|
|
|
// Class methods
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
+ (void) initialize
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if (self == [NSTextField class])
|
|
|
|
{
|
|
|
|
[self setVersion: 1];
|
|
|
|
[self setCellClass: [NSTextFieldCell class]];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Initializing the NSTextField Factory
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
+ (Class) cellClass
|
|
|
|
{
|
|
|
|
return _nsTextfieldCellClass;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ (void) setCellClass: (Class)classId
|
|
|
|
{
|
|
|
|
_nsTextfieldCellClass = classId;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
|
|
|
// Instance methods
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (id) init
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
return [self initWithFrame: NSZeroRect];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (id) initWithFrame: (NSRect)frameRect
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-10-18 19:24:45 +00:00
|
|
|
return [self _initFieldWithFrame:frameRect cellClass:_nsTextfieldCellClass];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
===============
|
|
|
|
-_initFieldWithFrame:cellClass:
|
|
|
|
===============
|
|
|
|
*/
|
|
|
|
- (id)_initFieldWithFrame:(NSRect)frameRect cellClass:(Class)cellClass
|
|
|
|
{
|
|
|
|
id c;
|
1999-04-01 06:22:28 +00:00
|
|
|
|
|
|
|
[super initWithFrame: frameRect];
|
1999-10-18 19:24:45 +00:00
|
|
|
c = [cellClass new];
|
1999-04-01 06:22:28 +00:00
|
|
|
[self setCell: c];
|
|
|
|
[c release];
|
|
|
|
[cell setState: 1];
|
1999-04-01 20:21:05 +00:00
|
|
|
[cell setBezeled: YES];
|
|
|
|
[cell setSelectable: YES];
|
1999-08-22 04:04:38 +00:00
|
|
|
[cell setEnabled: YES];
|
1999-04-01 20:21:05 +00:00
|
|
|
[cell setEditable: YES];
|
1999-09-09 02:56:20 +00:00
|
|
|
[self setDrawsBackground: YES];
|
1999-04-01 06:22:28 +00:00
|
|
|
text_cursor = [[NSCursor IBeamCursor] retain];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
return self;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) dealloc
|
1997-10-20 22:01:25 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
[text_cursor release];
|
|
|
|
[super dealloc];
|
1997-10-20 22:01:25 +00:00
|
|
|
}
|
|
|
|
|
1997-03-20 19:23:21 +00:00
|
|
|
//
|
|
|
|
// Creating copies
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) setTextCursor: (NSCursor *)aCursor
|
1997-03-20 19:23:21 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
[aCursor retain];
|
|
|
|
[text_cursor release];
|
|
|
|
text_cursor = aCursor;
|
1997-03-20 19:23:21 +00:00
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) copyWithZone: (NSZone*)zone
|
1997-03-20 19:23:21 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
id c;
|
1997-03-20 19:23:21 +00:00
|
|
|
|
1999-04-01 20:21:05 +00:00
|
|
|
c = [(id)super copyWithZone: zone];
|
1999-03-02 08:58:30 +00:00
|
|
|
[c setTextCursor: [NSCursor IBeamCursor]];
|
1997-03-20 19:23:21 +00:00
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
return c;
|
1997-03-20 19:23:21 +00:00
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Setting User Access to Text
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (BOOL) isEditable
|
|
|
|
{
|
|
|
|
return [cell isEditable];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isSelectable
|
|
|
|
{
|
|
|
|
return [cell isSelectable];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setEditable: (BOOL)flag
|
|
|
|
{
|
|
|
|
[cell setEditable: flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setSelectable: (BOOL)flag
|
|
|
|
{
|
|
|
|
[cell setSelectable: flag];
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Editing Text
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) selectText: (id)sender
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if ([[self window] makeFirstResponder: self])
|
|
|
|
[cell selectText: sender];
|
|
|
|
[self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Setting Tab Key Behavior
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (id) nextText
|
|
|
|
{
|
1999-10-12 15:05:37 +00:00
|
|
|
return _nextKeyView;
|
1999-04-01 06:22:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id) previousText
|
|
|
|
{
|
1999-10-12 15:05:37 +00:00
|
|
|
return _previousKeyView;
|
1999-04-01 06:22:28 +00:00
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) setNextText: (id)anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-10-12 15:05:37 +00:00
|
|
|
[self setNextKeyView: anObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) setPreviousText: (id)anObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-10-12 15:05:37 +00:00
|
|
|
[self setPreviousKeyView: anObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Assigning a Delegate
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) setDelegate: (id)anObject
|
|
|
|
{
|
|
|
|
text_delegate = anObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) delegate
|
|
|
|
{
|
|
|
|
return text_delegate;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Modifying Graphic Attributes
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) setBackgroundColor: (NSColor *)aColor
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
[cell setBackgroundColor: aColor];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (NSColor *) backgroundColor
|
|
|
|
{
|
|
|
|
return [cell backgroundColor];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) drawsBackground
|
|
|
|
{
|
|
|
|
return [cell drawsBackground];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isBezeled
|
|
|
|
{
|
|
|
|
return [cell isBezeled];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL) isBordered
|
|
|
|
{
|
|
|
|
return [cell isBordered];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setBezeled: (BOOL)flag
|
|
|
|
{
|
|
|
|
[cell setBezeled: flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setBordered: (BOOL)flag
|
|
|
|
{
|
|
|
|
[cell setBordered: flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setDrawsBackground: (BOOL)flag
|
|
|
|
{
|
|
|
|
[cell setDrawsBackground: flag];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setTextColor: (NSColor *)aColor
|
|
|
|
{
|
|
|
|
[cell setTextColor: aColor];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSColor *) textColor
|
|
|
|
{
|
|
|
|
return [cell textColor];
|
|
|
|
}
|
|
|
|
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Target and Action
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (SEL) errorAction
|
|
|
|
{
|
|
|
|
return error_action;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setErrorAction: (SEL)aSelector
|
|
|
|
{
|
|
|
|
error_action = aSelector;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
// Handling Events
|
1996-05-30 20:03:15 +00:00
|
|
|
//
|
1999-02-19 20:31:07 +00:00
|
|
|
- (void) mouseDown: (NSEvent*)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-02-19 20:31:07 +00:00
|
|
|
NSRect cellFrame = bounds;
|
|
|
|
|
|
|
|
if (![self isSelectable])
|
|
|
|
return;
|
1998-11-25 17:16:48 +00:00
|
|
|
|
|
|
|
fprintf(stderr, " TextField mouseDown --- ");
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
// location = [self convertPoint: [theEvent locationInWindow] fromView: nil];
|
1998-12-16 11:48:33 +00:00
|
|
|
// [self lockFocus];
|
1999-04-01 06:22:28 +00:00
|
|
|
// cellFrame = [self convertRect: frame toView: nil];
|
1999-06-22 00:02:42 +00:00
|
|
|
// cellFrame.origin = [super_view convertPoint: frame.origin
|
|
|
|
// toView: [window contentView]];
|
1998-12-16 11:48:33 +00:00
|
|
|
|
1999-02-19 20:31:07 +00:00
|
|
|
if ([cell isBordered])
|
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
cellFrame.origin.x += 1;
|
|
|
|
cellFrame.origin.y += 1;
|
|
|
|
cellFrame.size.width -= 2;
|
|
|
|
cellFrame.size.height -= 2;
|
|
|
|
}
|
|
|
|
else if ([cell isBezeled])
|
|
|
|
{
|
|
|
|
cellFrame.origin.x += 4;
|
|
|
|
cellFrame.origin.y += 2;
|
|
|
|
cellFrame.size.width -= 6;
|
|
|
|
cellFrame.size.height -= 4;
|
1999-02-19 20:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fprintf (stderr,
|
1998-12-16 11:48:33 +00:00
|
|
|
"XRTextField 0: rect origin (%1.2f, %1.2f), size (%1.2f, %1.2f)\n",
|
1999-04-01 06:22:28 +00:00
|
|
|
frame.origin.x, frame.origin.y,
|
1998-12-16 11:48:33 +00:00
|
|
|
frame.size.width, frame.size.height);
|
1999-02-19 20:31:07 +00:00
|
|
|
fprintf (stderr,
|
1998-12-16 11:48:33 +00:00
|
|
|
"XRTextField 1: rect origin (%1.2f, %1.2f), size (%1.2f, %1.2f)\n",
|
1999-04-01 06:22:28 +00:00
|
|
|
cellFrame.origin.x, cellFrame.origin.y,
|
1998-12-16 11:48:33 +00:00
|
|
|
cellFrame.size.width, cellFrame.size.height);
|
|
|
|
|
1999-02-19 20:31:07 +00:00
|
|
|
[cell editWithFrame: cellFrame
|
|
|
|
inView: self
|
1999-04-01 06:22:28 +00:00
|
|
|
editor: [window fieldEditor: YES forObject: cell]
|
|
|
|
delegate: self
|
1999-02-19 20:31:07 +00:00
|
|
|
event: theEvent];
|
1998-12-16 11:48:33 +00:00
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
// [[self cell] _setCursorLocation: location];
|
1998-12-16 11:48:33 +00:00
|
|
|
// [[self cell] _setCursorVisibility: YES];
|
1999-04-01 06:22:28 +00:00
|
|
|
// [cell drawWithFrame: bounds inView: self];
|
1998-12-16 11:48:33 +00:00
|
|
|
// [window flushWindow];
|
|
|
|
// [self unlockFocus];
|
1999-04-01 06:22:28 +00:00
|
|
|
// if ([[self window] makeFirstResponder: self])
|
|
|
|
// [self setNeedsDisplay: YES];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) mouseUp: (NSEvent *)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if (![self isSelectable])
|
|
|
|
return;
|
|
|
|
}
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) mouseMoved: (NSEvent *)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if (![self isSelectable])
|
|
|
|
return;
|
|
|
|
}
|
1998-11-25 17:16:48 +00:00
|
|
|
|
1999-10-12 15:05:37 +00:00
|
|
|
// This is called if a key is pressed when an editing session
|
|
|
|
// is not yet started. (If needed, we start it from here).
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) keyDown: (NSEvent *)theEvent
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
unsigned int key_code = [theEvent keyCode];
|
1999-10-12 15:05:37 +00:00
|
|
|
|
|
|
|
NSDebugLLog(@"NSText", @"NSTextField: -keyDown %s\n",
|
|
|
|
[[theEvent characters] cString]);
|
|
|
|
|
|
|
|
// If not editable then we ignore the key down, pass it on
|
|
|
|
if (![self isEditable])
|
|
|
|
{
|
|
|
|
[super keyDown: theEvent];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// If the key is TAB (with or without SHIFT) or ESC, pass it on
|
|
|
|
if ((key_code == 0x09) || (key_code == 0x1b))
|
|
|
|
{
|
|
|
|
[super keyDown: theEvent];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We handle ENTER here, to avoid setting up an editing session
|
|
|
|
// only for it.
|
|
|
|
if (key_code == 0x0d)
|
|
|
|
{
|
|
|
|
[window selectKeyViewFollowingView: self];
|
|
|
|
[self sendAction: [cell action] to: [cell target]];
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Otherwise, start an editing session (FIXME the following)
|
1999-04-01 06:58:28 +00:00
|
|
|
#if 1
|
|
|
|
{
|
|
|
|
NSRect cellFrame = bounds;
|
|
|
|
|
|
|
|
if ([cell isBordered])
|
|
|
|
{
|
|
|
|
cellFrame.origin.x += 1;
|
|
|
|
cellFrame.origin.y += 1;
|
|
|
|
cellFrame.size.width -= 2;
|
|
|
|
cellFrame.size.height -= 2;
|
|
|
|
}
|
|
|
|
else if ([cell isBezeled])
|
|
|
|
{
|
|
|
|
cellFrame.origin.x += 4;
|
|
|
|
cellFrame.origin.y += 2;
|
|
|
|
cellFrame.size.width -= 6;
|
|
|
|
cellFrame.size.height -= 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
[cell editWithFrame: cellFrame
|
|
|
|
inView: self
|
|
|
|
editor: [window fieldEditor: YES forObject: cell]
|
|
|
|
delegate: self
|
|
|
|
event: theEvent];
|
|
|
|
}
|
|
|
|
#else
|
1998-11-25 17:16:48 +00:00
|
|
|
// Hide the cursor during typing
|
|
|
|
[NSCursor hide];
|
|
|
|
|
|
|
|
[self lockFocus];
|
1999-04-01 06:22:28 +00:00
|
|
|
[[self cell] _handleKeyEvent: theEvent];
|
|
|
|
[cell drawWithFrame: bounds inView: self];
|
1998-11-25 17:16:48 +00:00
|
|
|
[window flushWindow];
|
|
|
|
[self unlockFocus];
|
1999-04-01 06:22:28 +00:00
|
|
|
// [self setNeedsDisplay: YES];
|
1999-04-01 06:58:28 +00:00
|
|
|
#endif
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (BOOL) acceptsFirstResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-08-22 04:04:38 +00:00
|
|
|
if ([self isSelectable] || [self isEditable])
|
1996-05-30 20:03:15 +00:00
|
|
|
return YES;
|
|
|
|
else
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (BOOL) becomeFirstResponder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-09-09 02:56:20 +00:00
|
|
|
if ([self isSelectable] || [self isEditable])
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
[cell selectText: self];
|
1996-05-30 20:03:15 +00:00
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if ([text_delegate respondsToSelector: @selector(textDidBeginEditing: )])
|
|
|
|
return [text_delegate textDidBeginEditing: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) textDidChange: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if ([text_delegate respondsToSelector: @selector(textDidChange: )])
|
|
|
|
return [text_delegate textDidChange: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) textDidEndEditing: (NSNotification *)aNotification
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-04-01 06:22:28 +00:00
|
|
|
if ([text_delegate respondsToSelector: @selector(textDidEndEditing: )])
|
|
|
|
return [text_delegate textDidEndEditing: aNotification];
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (BOOL) textShouldBeginEditing: (NSText *)textObject
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
|
|
|
return YES;
|
|
|
|
}
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
- (BOOL) textShouldEndEditing: (NSText *)aTextObject
|
|
|
|
{
|
|
|
|
if ([cell isEntryAcceptable: [aTextObject text]])
|
|
|
|
{
|
|
|
|
// if ([delegate respondsTo: control: textShouldEndEditing: ]) // FIX ME
|
1999-02-18 10:46:39 +00:00
|
|
|
// {
|
1999-04-01 06:22:28 +00:00
|
|
|
// if (![delegate control: textShouldEndEditing: ])
|
1999-02-18 10:46:39 +00:00
|
|
|
// {
|
|
|
|
// NSBeep();
|
|
|
|
// return NO;
|
|
|
|
// }
|
|
|
|
// else
|
|
|
|
// return YES;
|
|
|
|
// }
|
1999-04-01 06:22:28 +00:00
|
|
|
[cell endEditing: aTextObject];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{ // entry is not valid
|
|
|
|
NSBeep();
|
|
|
|
return NO;
|
|
|
|
}
|
1999-02-18 10:46:39 +00:00
|
|
|
|
1999-09-09 02:56:20 +00:00
|
|
|
// [self display];
|
|
|
|
// [window flushWindow];
|
|
|
|
|
1999-04-01 06:22:28 +00:00
|
|
|
return YES;
|
1996-05-30 20:03:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1997-03-05 01:11:17 +00:00
|
|
|
// Manage the cursor
|
|
|
|
//
|
1999-04-01 06:22:28 +00:00
|
|
|
- (void) resetCursorRects
|
1997-03-05 01:11:17 +00:00
|
|
|
{
|
|
|
|
[self addCursorRect: bounds cursor: text_cursor];
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
1996-05-30 20:03:15 +00:00
|
|
|
// NSCoding protocol
|
|
|
|
//
|
1999-03-02 08:58:30 +00:00
|
|
|
- (void) encodeWithCoder: (NSCoder*)aCoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
[super encodeWithCoder: aCoder];
|
|
|
|
|
|
|
|
[aCoder encodeConditionalObject: text_delegate];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aCoder encodeValueOfObjCType: @encode(SEL) at: &error_action];
|
|
|
|
}
|
|
|
|
|
1999-03-02 08:58:30 +00:00
|
|
|
- (id) initWithCoder: (NSCoder*)aDecoder
|
1996-05-30 20:03:15 +00:00
|
|
|
{
|
1999-03-02 08:58:30 +00:00
|
|
|
[super initWithCoder: aDecoder];
|
1996-05-30 20:03:15 +00:00
|
|
|
|
1997-02-18 00:29:25 +00:00
|
|
|
text_delegate = [aDecoder decodeObject];
|
1996-05-30 20:03:15 +00:00
|
|
|
[aDecoder decodeValueOfObjCType: @encode(SEL) at: &error_action];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
|
|
|
|