From 9b7f8ec31ee477f4928fa749dd85fe90babbaf3b Mon Sep 17 00:00:00 2001 From: Andreas Date: Mon, 12 Jul 2010 11:19:28 +0200 Subject: [PATCH] Add -insertTabIgnoringFieldEditor: and -insertNewlineIgnoringFieldEditor: --- AppKit/CPTextField.j | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 660c43e65..0762c791d 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -715,6 +715,25 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [[[self window] platformWindow] _propagateCurrentDOMEvent:NO]; } +- (void)insertNewlineIgnoringFieldEditor:(id)sender +{ + var oldValue = [self stringValue]; + + [self _inputElement].value += CPNewlineCharacter; + [self _setStringValue:[self _inputElement].value]; + + if (oldValue !== [self stringValue]) + { + if (!_isEditing) + { + _isEditing = YES; + [self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]]; + } + + [self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]]; + } +} + - (void)selectNextKeyView:(id)sender { [[self window] selectNextKeyView:self]; @@ -740,6 +759,25 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); [self selectNextKeyView:sender]; } +- (void)insertTabIgnoringFieldEditor:(id)sender +{ + var oldValue = [self stringValue]; + + [self _inputElement].value += CPTabCharacter; + [self _setStringValue:[self _inputElement].value]; + + if (oldValue !== [self stringValue]) + { + if (!_isEditing) + { + _isEditing = YES; + [self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]]; + } + + [self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]]; + } +} + - (void)insertBacktab:(id)sender { [self selectPreviousKeyView:sender];