Fixes for undoing in the field editor. Added usage of NSCellUndoManager class.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_testplant_branch@38903 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Paul Landers 2015-08-17 17:41:37 +00:00
parent 71dd745382
commit 9bcec86989
4 changed files with 30 additions and 2 deletions

View file

@ -248,6 +248,8 @@ therefore be stored in the NSLayoutManager to avoid problems.
// Text checking (spelling/grammar)
NSTimer *_textCheckingTimer;
NSRect _lastCheckedRect;
NSUndoManager *_fieldEditorUndoManager;
}
@ -344,6 +346,7 @@ to the set of non-range taking varieties. */
-(void) setAllowsUndo: (BOOL)flag; /* mosx */
-(BOOL) smartInsertDeleteEnabled;
-(void) setSmartInsertDeleteEnabled: (BOOL)flag;
-(void)_setFieldEditorUndoManager:(NSUndoManager *)undoManager;
/* These methods are like paste: (from NSResponder) but they restrict

View file

@ -48,6 +48,7 @@
@class NSNotification;
@class NSString;
@class NSUndoManager;
@class NSCellUndoManager;
@class NSButton;
@class NSButtonCell;

View file

@ -2318,6 +2318,16 @@ static NSColor *dtxtCol;
_cell.shows_first_responder = YES;
_cell.in_editing = YES;
if ([textObject isKindOfClass:[NSTextView class]])
{
NSCellUndoManager * undoManager = [[NSCellUndoManager alloc] init];
[undoManager setNextUndoManager:[[controlView window] undoManager]];
[(NSTextView *)textObject _setFieldEditorUndoManager:undoManager];
[undoManager release];
[(NSTextView *)textObject setAllowsUndo:YES];
}
#if 0
// Testplant-MAL-2015-06-20: merging removal causes focus ring issues...
// FIXME: we need to draw the focus ring, this works but

View file

@ -1137,6 +1137,7 @@ that makes decoding and encoding compatible with the old code.
DESTROY(_defaultParagraphStyle);
DESTROY(_linkTextAttributes);
DESTROY(_undoObject);
DESTROY(_fieldEditorUndoManager);
[super dealloc];
}
@ -1705,7 +1706,7 @@ to make sure syncing is handled properly in all cases.
[notificationCenter postNotificationName: NSTextDidEndEditingNotification
object: _notifObject];
if (_tf.is_field_editor)
if (_tf.is_field_editor && ![[self undoManager] isUndoing] && ![[self undoManager] isRedoing] )
{
[[self undoManager] removeAllActions];
}
@ -2603,12 +2604,25 @@ Move to NSTextView_actions.m?
if (![_delegate respondsToSelector: @selector(undoManagerForTextView:)]
|| ((undo = [_delegate undoManagerForTextView: self]) == nil))
{
undo = [super undoManager];
if (_fieldEditorUndoManager)
{
undo = _fieldEditorUndoManager;
}
else
{
undo = [super undoManager];
}
}
return undo;
}
-(void)_setFieldEditorUndoManager:(NSUndoManager *)undoManager
{
[_fieldEditorUndoManager autorelease];
_fieldEditorUndoManager = [undoManager retain];
}
/*
* Began editing flag. There are quite some different ways in which
* editing can be started. Each time editing is started, we need to check