Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

This adds basic undo/redo to LPMultilineTextField #25

Open
wants to merge 3 commits into from

1 participant

This page is out of date. Refresh to see the latest.
Showing with 4 additions and 7 deletions.
  1. +4 −7 LPMultiLineTextField.j
View
11 LPMultiLineTextField.j
@@ -184,6 +184,8 @@ var CPTextFieldInputOwner = nil;
{
if (_stringValue !== [self stringValue])
{
+ [[[[self window] undoManager] prepareWithInvocationTarget:self] setStringValue:_stringValue];
+ [[[self window] undoManager] setActionName:@"Typing"];
_stringValue = [self stringValue];
if (!_isEditing)
@@ -207,14 +209,7 @@ var CPTextFieldInputOwner = nil;
- (BOOL)becomeFirstResponder
{
_stringValue = [self stringValue];
-
[self setThemeState:CPThemeStateEditing];
-
- setTimeout(function(){
- [self _DOMTextareaElement].focus();
- CPTextFieldInputOwner = self;
- }, 0.0);
-
[self textDidFocus:[CPNotification notificationWithName:CPTextFieldDidFocusNotification object:self userInfo:nil]];
return YES;
@@ -250,6 +245,8 @@ var CPTextFieldInputOwner = nil;
- (void)setStringValue:(CPString)aString
{
+ if(_stringValue != aString)
+ [[[[self window] undoManager] prepareWithInvocationTarget:self] setStringValue:_stringValue];
_stringValue = aString;
[self setNeedsLayout];
}
Something went wrong with that request. Please try again.