fixed: undo support for fontpanel

This commit is contained in:
daboe01 committed 2016-05-24 10:56:19 +02:00
1 parent 7e622f1153
commit 7d2eb83a1b
1 file changed
+12 -1
+12 -1
View File
@@ -1479,6 +1479,12 @@ var kDelegateRespondsTo_textShouldBeginEditing
[_textStorage setFont:_font];
}
var currentAttributes = [_textStorage attributesAtIndex:range.location effectiveRange:nil] || _typingAttributes;
[[[[self window] undoManager] prepareWithInvocationTarget:self]
setFont:[currentAttributes objectForKey:CPFontAttributeName] || _font
range:CPMakeRangeCopy(range)];
[_textStorage addAttribute:CPFontAttributeName value:font range:CPMakeRangeCopy(range)];
[_layoutManager _validateLayoutAndGlyphs];
}
@@ -1488,7 +1494,10 @@ var kDelegateRespondsTo_textShouldBeginEditing
var currRange = CPMakeRange(_selectionRange.location, 0),
oldFont,
attributes,
scrollRange = CPMakeRange(CPMaxRange(_selectionRange), 0);
scrollRange = CPMakeRange(CPMaxRange(_selectionRange), 0),
undoManager = [[self window] undoManager];
[undoManager beginUndoGrouping];
if ([self isRichText])
{
@@ -1518,6 +1527,8 @@ var kDelegateRespondsTo_textShouldBeginEditing
scrollRange = CPMakeRange(length, 0);
}
[undoManager endUndoGrouping];
[_layoutManager _validateLayoutAndGlyphs];
[self sizeToFit];
[self setNeedsDisplay:YES];