From 9d43a559fe87a313f2d628c56428701ec9f5b336 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Mon, 19 Aug 2013 21:36:07 +0100 Subject: [PATCH] Fixed: - CPTextField deleteBackward: required selection. According to the spec, deleteBackward: should remove the element before the insertion point if there is no selection (e.g. actually delete backwards). --- AppKit/CPTextField.j | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/AppKit/CPTextField.j b/AppKit/CPTextField.j index 90638db9b..2c4502304 100644 --- a/AppKit/CPTextField.j +++ b/AppKit/CPTextField.j @@ -1506,10 +1506,15 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder"); var selectedRange = [self selectedRange]; - // FIXME Is deleteBackward: meant to delete the character before the caret if there's no - // selection? There's no official documentation on deleteBackward: in Cocoa. if (selectedRange.length < 1) - return; + { + if (selectedRange.location < 1) + return; + + // Delete a single element backward from the insertion point if there's no selection. + selectedRange.location -= 1; + selectedRange.length += 1; + } var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];