Fixed: copying from a CPTextField would not actually but the string value in the Cappuccino pasteboard.

Without this fix, when text was copied from a CPTextField, the value would be copied into the system clipboard (if possible), but not into the Cappuccino pasteboard. This meant that the text could not be pasted back in Cappuccino using e.g. Edit > Paste from the Cappuccino menu.

This fix ensures the appropriate text is copied both into Cappuccino's pasteboard and the system clipboard (when possible).
This commit is contained in:
Alexander Ljungberg committed 2013-06-14 14:31:00 +01:00
1 parent a4aed913d7
commit 198857e0ad
1 file changed
+19 -17
+19 -17
View File
@@ -1269,37 +1269,39 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
- (void)copy:(id)sender
{
if (![CPPlatform isBrowser])
// First write to the Cappuccino clipboard.
var selectedRange = [self selectedRange];
if (selectedRange.length < 1)
return;
var pasteboard = [CPPasteboard generalPasteboard],
stringForPasting = [_stringValue substringWithRange:selectedRange];
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
[pasteboard setString:stringForPasting forType:CPStringPboardType];
if ([CPPlatform isBrowser])
{
var selectedRange = [self selectedRange];
if (selectedRange.length < 1)
return;
var pasteboard = [CPPasteboard generalPasteboard],
stringForPasting = [_stringValue substringWithRange:selectedRange];
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
[pasteboard setString:stringForPasting forType:CPStringPboardType];
}
else
// Allow the browser's standard copy handling.
// Then also allow the browser to capture the copied text into the system clipboard.
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
}
}
- (void)cut:(id)sender
{
[self copy:sender];
if (![CPPlatform isBrowser])
{
[self copy:sender];
[self deleteBackward:sender];
}
// If we don't have an oninput listener, we won't detect the change made by the cut and need to fake a key up "soon".
else
{
// Allow the browser's standard cut handling.
// Allow the browser's standard cut handling. This should also result in the deleteBackward: happening.
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
// If we don't have an oninput listener, we won't detect the change made by the cut and need to fake a key up "soon".
if (!CPFeatureIsCompatible(CPInputOnInputEventFeature))
[CPTimer scheduledTimerWithTimeInterval:0.0 target:self selector:@selector(keyUp:) userInfo:nil repeats:NO];
}