From 0d7e9456233b5c39ee232d62f428153df0ffc737 Mon Sep 17 00:00:00 2001 From: daboe01 Date: Mon, 22 Jun 2015 20:30:44 +0200 Subject: [PATCH] fix native cut --- AppKit/CPTextView/CPTextView.j | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/AppKit/CPTextView/CPTextView.j b/AppKit/CPTextView/CPTextView.j index 6267198af..cc487244b 100644 --- a/AppKit/CPTextView/CPTextView.j +++ b/AppKit/CPTextView/CPTextView.j @@ -2282,6 +2282,30 @@ var _CPCopyPlaceholder = '-'; e.preventDefault(); e.stopPropagation(); + return false; + } + _CPNativeInputField.oncut = function(e) + { + _CPNativeInputFieldWasCopyPaste = YES; + + var pasteboard = [CPPasteboard generalPasteboard], + string, + currentFirstResponder = [[CPApp mainWindow] firstResponder]; + + setTimeout(function(){ // prevent dom-flickering + [currentFirstResponder cut:self]; + }, 20); + + [currentFirstResponder copy:self]; // this is necessary because cut will only execute in the future + // dataForPasting = [pasteboard dataForType:CPRichStringPboardType], + stringForPasting = [pasteboard stringForType:CPStringPboardType]; + + e.clipboardData.setData('text/plain', stringForPasting); + // e.clipboardData.setData('application/rtf', stringForPasting); // does not seem to work + + e.preventDefault(); + e.stopPropagation(); + return false; } }