(-shouldChangeTextInRange:replacementString:, -didChangeText): Allow changes even if we're not the first responder, but end the editing session right away.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15844 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2003-02-01 14:14:53 +00:00
parent 2169264f00
commit 6f524e43b8
2 changed files with 37 additions and 3 deletions

View file

@ -1,3 +1,11 @@
2003-02-01 15:09 Alexander Malmberg <alexander@malmberg.org>
* Source/NSTextView.m (-shouldChangeTextInRange:replacementString:):
Allow changes even if we're not the first responder.
(-didChangeText): If we're not the first responder, end the editing
session.
2003-02-01 13:52 Alexander Malmberg <alexander@malmberg.org>
* Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): Fix

View file

@ -1565,6 +1565,8 @@ This method is for user changes; see NSTextView_actions.m.
return;
}
/*printf("-insertText: range %i+%i |%@|\n",insertRange.location,insertRange.length,insertString);
printf(" text storage length %i\n",[self textLength]);*/
isAttributed = [insertString isKindOfClass: [NSAttributedString class]];
if (isAttributed)
@ -1610,6 +1612,7 @@ This method is for user changes; see NSTextView_actions.m.
[self didChangeText];
/* TODO? move cursor <!> [self selectionRangeForProposedRange: ] */
//printf(" text storage length now %i\n",[self textLength]);
[self setSelectedRange:
NSMakeRange(insertRange.location + [insertString length], 0)];
}
@ -1989,6 +1992,15 @@ called anyway.
To be safe, changes are currently always disallowed if the text view
isn't the first responder.
(2003-02-01): GNUMail does it by having an "attach" button when editing
mails. It adds an attachment to the text using -insertText:, and it is
a fairly reasonable thing to do.
Thus, if we aren't the first responder, we still proceed as normal here.
In -didChangeText, if we still aren't the first responder, we send the
TextDidEndEditing notification _without_ asking the delegate
(-; since we can't handle a NO return).
*/
-(BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange
replacementString: (NSString *)replacementString
@ -1996,9 +2008,6 @@ isn't the first responder.
if (_tf.is_editable == NO)
return NO;
if ([_window firstResponder] != self)
return NO;
/*
We need to send the textShouldBeginEditing: /
@ -2033,6 +2042,22 @@ After each user-induced change, this method should be called.
{
[notificationCenter postNotificationName: NSTextDidChangeNotification
object: _notifObject];
if ([_window firstResponder] != self)
{ /* Copied from -resignFirstResponder . See comment above. */
if ([self shouldDrawInsertionPoint])
{
[self updateInsertionPointStateAndRestartTimer: NO];
}
if (_layoutManager != nil)
{
_layoutManager->_beganEditing = NO;
}
[notificationCenter postNotificationName: NSTextDidEndEditingNotification
object: _notifObject];
}
}
/*
@ -2447,6 +2472,7 @@ afterString in order over charRange.
- (void) setSelectedRange: (NSRange)charRange
{
// printf("-setSelectedRange: %i+%i\n",charRange.location,charRange.length);
[self setSelectedRange: charRange affinity: [self selectionAffinity]
stillSelecting: NO];
}