mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-28 17:32:03 +00:00
fixed: drag placeholder was CPTextField instead of CPTextView
This commit is contained in:
1 parent
1492763d0c
commit
1206654d98
1 file changed
+11
-20
@@ -939,33 +939,24 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
if ([self selectionGranularity] == CPSelectByCharacter && CPLocationInRange(_startTrackingLocation, _selectionRange))
|
||||
{
|
||||
_movingSelection = CPMakeRange(_startTrackingLocation, 0);
|
||||
var dragPlaceholder = [CPTextField new],
|
||||
originPoint = [_layoutManager locationForGlyphAtIndex:_selectionRange.location];
|
||||
|
||||
originPoint.x += _textContainerOrigin.x;
|
||||
originPoint.y += _textContainerOrigin.y;
|
||||
|
||||
dragPlaceholder._DOMElement.style.opacity = '0.4';
|
||||
var attributes = [_textStorage attributesAtIndex:_selectionRange.location effectiveRange:nil];
|
||||
[dragPlaceholder setFont:[attributes objectForKey:CPFontAttributeName]];
|
||||
[dragPlaceholder setTextColor:[attributes objectForKey:CPForegroundColorAttributeName]];
|
||||
var effectiveRange = CPIntersectionRange(CPMakeRange(_selectionRange.location, 10), _selectionRange),
|
||||
placeholderString = [[self stringValue] substringWithRange:effectiveRange];
|
||||
|
||||
if (_selectionRange.length > 10)
|
||||
placeholderString += '...';
|
||||
|
||||
[dragPlaceholder setStringValue:placeholderString];
|
||||
[dragPlaceholder sizeToFit];
|
||||
var placeholderRect = CGRectIntersection([_layoutManager boundingRectForGlyphRange:_selectionRange inTextContainer:_textContainer], _frame),
|
||||
dragPlaceholder;
|
||||
|
||||
placeholderRect.size.width += 10; // prevent wrapping
|
||||
dragPlaceholder = [[CPTextView alloc] initWithFrame:placeholderRect];
|
||||
[dragPlaceholder insertText:[_textStorage attributedSubstringFromRange:CPMakeRangeCopy(_selectionRange)]];
|
||||
#if PLATFORM(DOM)
|
||||
dragPlaceholder._DOMElement.style.backgroundColor = "transparent";
|
||||
dragPlaceholder._DOMElement.style.opacity = "0.5";
|
||||
#endif
|
||||
var stringForPasting = [_textStorage attributedSubstringFromRange:CPMakeRangeCopy(_selectionRange)],
|
||||
richData = [_CPRTFProducer produceRTF:stringForPasting documentAttributes:@{}],
|
||||
draggingPasteboard = [CPPasteboard pasteboardWithName:CPDragPboard];
|
||||
[draggingPasteboard declareTypes:[CPRTFPboardType] owner:nil];
|
||||
[draggingPasteboard setString:richData forType:CPRTFPboardType];
|
||||
|
||||
|
||||
[self dragView:dragPlaceholder
|
||||
at:originPoint
|
||||
at:placeholderRect.origin
|
||||
offset:nil
|
||||
event:event
|
||||
pasteboard:draggingPasteboard
|
||||
|
||||
Reference in new issue
Block a user