From d5918157ffe9603d7d5be4e93d51ba79efbf6654 Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Fri, 15 Jun 2012 22:11:52 +0100 Subject: [PATCH] Overwrite selected tokens by typing support. If tokens are selected in `CPTokenField` and new text is entered, the selected tokens are overwritten by the newly entered text. --- AppKit/CPTokenField.j | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/AppKit/CPTokenField.j b/AppKit/CPTokenField.j index 943d593b0..8904846c9 100755 --- a/AppKit/CPTokenField.j +++ b/AppKit/CPTokenField.j @@ -699,6 +699,14 @@ var CPScrollDestinationNone = 0, } else { + // If you type something while tokens are selected, overwrite them. + if (_selectedRange.length) + { + [self _removeSelectedTokens:self]; + // Make sure the editor is placed so it can capture the characters we're overwriting with. + [self layoutSubviews]; + } + // If we didn't handle it, allow _propagateCurrentDOMEvent the input field to receive // the new character.