FF copy paste fix

This commit is contained in:
daboe01
2015-07-01 22:52:01 +02:00
parent 59162155de
commit d22a7c0a63
2 changed files with 54 additions and 3 deletions
+52 -2
View File
@@ -224,8 +224,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
- (void)paste:(id)sender
{
var e = [CPApp currentEvent]._DOMEvent;
if (e.currentTarget == document) // this is somehow necessary to prevent double pasting
if (e && e.currentTarget == document) // this is somehow necessary to prevent double pasting
return;
var stringForPasting = [self _stringForPasting];
@@ -2210,6 +2209,57 @@ var _CPCopyPlaceholder = '-';
return false;
}, true); // capture mode
if (CPBrowserIsEngine(CPGeckoBrowserEngine))
{
_CPNativeInputField.onpaste = function(e)
{
var pasteboard = [CPPasteboard generalPasteboard];
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
var data = e.clipboardData.getData('text/plain');
[pasteboard setString:data forType:CPStringPboardType];
var currentFirstResponder = [[CPApp mainWindow] firstResponder];
setTimeout(function(){ // prevent dom-flickering
[currentFirstResponder paste:self];
}, 20);
return false;
}
_CPNativeInputField.oncopy = function(e)
{
var pasteboard = [CPPasteboard generalPasteboard],
string,
currentFirstResponder = [[CPApp mainWindow] firstResponder];
[currentFirstResponder copy:self];
// 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
return false;
}
_CPNativeInputField.oncut = function(e)
{
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
return false;
}
}
}
+ (void)focus