From 6d877754da8c2c7a461b90046e19c43ff99a16ba Mon Sep 17 00:00:00 2001 From: daboe01 Date: Sat, 27 Jun 2015 13:10:53 +0200 Subject: [PATCH] focusForClipboard fixes --- AppKit/CPTextView/CPTextView.j | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 122a2bd4d..046497c4f 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -2315,7 +2315,6 @@ var _CPCopyPlaceholder = '-'; + (void)focus { - var currentFirstResponder = [[CPApp mainWindow] firstResponder]; if (![currentFirstResponder respondsToSelector:@selector(_activateNativeInputElement:)]) @@ -2341,6 +2340,14 @@ var _CPCopyPlaceholder = '-'; currentFirstResponder._DOMElement.appendChild(_CPNativeInputField); _CPNativeInputField.focus(); +} + ++ (void)focusForClipboard +{ + if (!_CPNativeInputFieldActive && _CPNativeInputField.innerHTML.length == 0) + _CPNativeInputField.innerHTML = _CPCopyPlaceholder; // make sure we have a selection to allow the native pasteboard work in safari + + [self focus]; // select all in the contenteditable div (http://stackoverflow.com/questions/12243898/how-to-select-all-text-in-contenteditable-div) if (document.body.createTextRange) @@ -2358,14 +2365,6 @@ var _CPCopyPlaceholder = '-'; } } -+ (void)focusForClipboard -{ - if (_CPNativeInputField.innerHTML.length == 0) - _CPNativeInputField.innerHTML = _CPCopyPlaceholder; // make sure we have a selection to allow the native pasteboard work in safari - - [self focus]; -} - + (void)hideInputElement { _CPNativeInputField.style.top="-10000px";