mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-20 09:20:41 +00:00
FF copy paste fix
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user