mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge branch 'master' of https://github.com/cappuccino/cappuccino into protocol
This commit is contained in:
@@ -12,5 +12,6 @@ xcuserdata/
|
||||
*.xCodeSupport/
|
||||
*.XcodeSupport/
|
||||
*XcodeSupport/
|
||||
Tests/Manual/**/*.xcodeproj
|
||||
*.sublime-project
|
||||
*.sublime-workspace
|
||||
|
||||
+167
-84
@@ -351,8 +351,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
else
|
||||
[self unsetThemeState:CPThemeStateEditable];
|
||||
|
||||
// We only allow first responder status if the field is editable and enabled.
|
||||
if (!shouldBeEditable && [[self window] firstResponder] === self)
|
||||
// We only allow first responder status if the field is enable, and editable or selectable.
|
||||
if (!(shouldBeEditable && ![self isSelectable]) && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
|
||||
if (shouldBeEditable)
|
||||
@@ -377,7 +377,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
{
|
||||
[super setEnabled:shouldBeEnabled];
|
||||
|
||||
// We only allow first responder status if the field is editable and enabled.
|
||||
// We only allow first responder status if the field is enabled.
|
||||
if (!shouldBeEnabled && [[self window] firstResponder] === self)
|
||||
[[self window] makeFirstResponder:nil];
|
||||
}
|
||||
@@ -531,18 +531,21 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
/*! @ignore */
|
||||
- (BOOL)acceptsFirstResponder
|
||||
{
|
||||
return [self isEditable] && [self isEnabled] && [self _isWithinUsablePlatformRect];
|
||||
return ([self isEnabled] && [self isEditable] || [self isSelectable]) && [self _isWithinUsablePlatformRect];
|
||||
}
|
||||
|
||||
/*! @ignore */
|
||||
- (BOOL)becomeFirstResponder
|
||||
{
|
||||
if (![self isEnabled])
|
||||
return NO;
|
||||
|
||||
// As long as we are the first responder we need to monitor the key status of our window.
|
||||
[self _setObserveWindowKeyNotifications:YES];
|
||||
|
||||
_isEditing = NO;
|
||||
|
||||
if ([[self window] isKeyWindow])
|
||||
if ([[self window] isKeyWindow] && [self isEditable])
|
||||
return [self _becomeFirstKeyResponder];
|
||||
|
||||
return YES;
|
||||
@@ -552,6 +555,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
A text field can be the first responder without necessarily being the focus of keyboard input. For example, it might be the first responder of window A but window B is the main and key window. It's important we don't put a focused input field into a text field in a non-key window, even if that field is the first responder, because the key window might also have a first responder text field which the user will expect to receive keyboard input.
|
||||
|
||||
Since a first responder but non-key window text field can't receive input it should not even look like an active text field (Cocoa has a "slightly active" text field look it uses when another window is the key window, but Cappuccino doesn't today.)
|
||||
|
||||
It's also possible for a text field to be non-editable but selectable in which case it can also become the first responder -
|
||||
this is what allows text to be copied from it.
|
||||
*/
|
||||
- (BOOL)_becomeFirstKeyResponder
|
||||
{
|
||||
@@ -560,6 +566,11 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
if (![self _isWithinUsablePlatformRect])
|
||||
return NO;
|
||||
|
||||
// A selectable but non-editable text field may be the first responder, but never the
|
||||
// first key responder (first key responder indicating editability.)
|
||||
if (![self isEditable])
|
||||
return NO;
|
||||
|
||||
[self setThemeState:CPThemeStateEditing];
|
||||
|
||||
[self _updatePlaceholderState];
|
||||
@@ -680,24 +691,26 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (BOOL)resignFirstResponder
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var element = [self _inputElement],
|
||||
newValue = element.value,
|
||||
error = @"";
|
||||
|
||||
if (newValue !== _stringValue)
|
||||
// We might have been the first responder without actually editing.
|
||||
if (_isEditing)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
}
|
||||
var element = [self _inputElement],
|
||||
newValue = element.value,
|
||||
error = @"";
|
||||
|
||||
// If there is a formatter, always give it a chance to reject the resignation,
|
||||
// even if the value has not changed.
|
||||
if ([self _valueIsValid:newValue] === NO)
|
||||
{
|
||||
element.focus();
|
||||
return NO;
|
||||
}
|
||||
if (newValue !== _stringValue)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
}
|
||||
|
||||
// If there is a formatter, always give it a chance to reject the resignation,
|
||||
// even if the value has not changed.
|
||||
if ([self _valueIsValid:newValue] === NO)
|
||||
{
|
||||
element.focus();
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// When we are no longer the first responder we don't worry about the key status of our window anymore.
|
||||
@@ -706,10 +719,13 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
[self _resignFirstKeyResponder];
|
||||
|
||||
_isEditing = NO;
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
if ([self isEditable])
|
||||
{
|
||||
[self textDidEndEditing:[CPNotification notificationWithName:CPControlTextDidEndEditingNotification object:self userInfo:nil]];
|
||||
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
if ([self sendsActionOnEndEditing])
|
||||
[self sendAction:[self action] to:[self target]];
|
||||
}
|
||||
|
||||
[self textDidBlur:[CPNotification notificationWithName:CPTextFieldDidBlurNotification object:self userInfo:nil]];
|
||||
|
||||
@@ -782,6 +798,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)_windowDidBecomeKey:(CPNotification)aNotification
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var wind = [self window];
|
||||
|
||||
if ([wind isKeyWindow] && [wind firstResponder] === self)
|
||||
@@ -828,6 +847,17 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
return [self acceptsFirstResponder];
|
||||
}
|
||||
|
||||
- (void)_didEdit
|
||||
{
|
||||
if (!_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
- (void)mouseDown:(CPEvent)anEvent
|
||||
{
|
||||
// Don't track! (ever?)
|
||||
@@ -854,7 +884,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)mouseUp:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isSelectable] && (![self isEditable] || ![self isEnabled]))
|
||||
if (![self isEnabled] || !([self isSelectable] || [self isEditable]))
|
||||
[[self nextResponder] mouseUp:anEvent];
|
||||
else if ([self isSelectable])
|
||||
{
|
||||
@@ -866,13 +896,22 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
CPTextFieldCachedSelectStartFunction = nil
|
||||
CPTextFieldCachedDragFunction = nil;
|
||||
}
|
||||
|
||||
// TODO clickCount === 2 should select the clicked word.
|
||||
|
||||
if ([[CPApp currentEvent] clickCount] === 3)
|
||||
{
|
||||
[self selectText:nil];
|
||||
return;
|
||||
}
|
||||
|
||||
return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)mouseDragged:(CPEvent)anEvent
|
||||
{
|
||||
if (![self isSelectable] && (![self isEditable] || ![self isEnabled]))
|
||||
if (![self isEnabled] || !([self isSelectable] || [self isEditable]))
|
||||
[[self nextResponder] mouseDragged:anEvent];
|
||||
else if ([self isSelectable])
|
||||
return [[[anEvent window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
@@ -880,26 +919,21 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)keyUp:(CPEvent)anEvent
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var newValue = [self _inputElement].value;
|
||||
|
||||
if (newValue !== _stringValue)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
|
||||
if (!_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
[[[self window] platformWindow] _propagateCurrentDOMEvent:YES];
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)keyDown:(CPEvent)anEvent
|
||||
@@ -932,11 +966,15 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)insertNewline:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var newValue = [self _inputElement].value;
|
||||
|
||||
if (newValue !== _stringValue)
|
||||
{
|
||||
[self _setStringValue:newValue];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
if ([self _valueIsValid:_stringValue])
|
||||
@@ -975,6 +1013,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)_insertCharacterIgnoringFieldEditor:(CPString)aCharacter
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var oldValue = _stringValue,
|
||||
@@ -987,13 +1028,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
// NOTE: _stringValue is now the current input element value
|
||||
if (oldValue !== _stringValue)
|
||||
{
|
||||
if (!_isEditing)
|
||||
{
|
||||
_isEditing = YES;
|
||||
[self textDidBeginEditing:[CPNotification notificationWithName:CPControlTextDidBeginEditingNotification object:self userInfo:nil]];
|
||||
}
|
||||
|
||||
[self textDidChange:[CPNotification notificationWithName:CPControlTextDidChangeNotification object:self userInfo:nil]];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1243,22 +1278,29 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)_selectText:(id)sender immediately:(BOOL)immediately
|
||||
{
|
||||
// Selecting the text in a field makes it the first responder
|
||||
if (([self isEditable] || [self isSelectable]))
|
||||
if ([self isEditable] || [self isSelectable])
|
||||
{
|
||||
var wind = [self window];
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
var element = [self _inputElement];
|
||||
|
||||
if ([wind firstResponder] === self)
|
||||
if ([self isEditable])
|
||||
{
|
||||
if (immediately)
|
||||
element.select();
|
||||
else
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
var element = [self _inputElement];
|
||||
|
||||
if ([wind firstResponder] === self)
|
||||
{
|
||||
if (immediately)
|
||||
element.select();
|
||||
else
|
||||
window.setTimeout(function() { element.select(); }, 0);
|
||||
}
|
||||
else if (wind !== nil && [wind makeFirstResponder:self])
|
||||
[self _selectText:sender immediately:immediately];
|
||||
}
|
||||
else
|
||||
{
|
||||
[self setSelectedRange:CPMakeRange(0, _stringValue.length)];
|
||||
}
|
||||
else if (wind !== nil && [wind makeFirstResponder:self])
|
||||
[self _selectText:sender immediately:immediately];
|
||||
#else
|
||||
// Even if we can't actually select the text we need to preserve the first
|
||||
// responder side effect.
|
||||
@@ -1272,16 +1314,30 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
- (void)copy:(id)sender
|
||||
{
|
||||
// First write to the Cappuccino clipboard.
|
||||
var selectedRange = [self selectedRange];
|
||||
var stringToCopy = nil;
|
||||
|
||||
if (selectedRange.length < 1)
|
||||
return;
|
||||
if ([self isEditable])
|
||||
{
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
var pasteboard = [CPPasteboard generalPasteboard],
|
||||
stringForPasting = [_stringValue substringWithRange:selectedRange];
|
||||
if (selectedRange.length < 1)
|
||||
return;
|
||||
|
||||
stringToCopy = [_stringValue substringWithRange:selectedRange];
|
||||
}
|
||||
else
|
||||
{
|
||||
// selectedRange won't work if we're displaying our text using a <div>. Instead we have to ask the browser
|
||||
// what's selected and hope it's right in a Cappuccino context as well.
|
||||
#if PLATFORM(DOM)
|
||||
stringToCopy = [[[self window] platformWindow] _selectedText];
|
||||
#endif
|
||||
}
|
||||
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
|
||||
[pasteboard declareTypes:[CPStringPboardType] owner:nil];
|
||||
[pasteboard setString:stringForPasting forType:CPStringPboardType];
|
||||
[pasteboard setString:stringToCopy forType:CPStringPboardType];
|
||||
|
||||
if ([CPPlatform isBrowser])
|
||||
{
|
||||
@@ -1292,8 +1348,14 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)cut:(id)sender
|
||||
{
|
||||
if (![self isEnabled])
|
||||
return;
|
||||
|
||||
[self copy:sender];
|
||||
|
||||
if (![self isEditable])
|
||||
return;
|
||||
|
||||
if (![CPPlatform isBrowser])
|
||||
{
|
||||
[self deleteBackward:sender];
|
||||
@@ -1311,6 +1373,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)paste:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
if (![CPPlatform isBrowser])
|
||||
{
|
||||
var pasteboard = [CPPasteboard generalPasteboard];
|
||||
@@ -1324,7 +1389,8 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
pasteString = [pasteboard stringForType:CPStringPboardType],
|
||||
newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:pasteString];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self _setStringValue:newValue];
|
||||
[self _didEdit];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location + pasteString.length, 0)];
|
||||
}
|
||||
// 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".
|
||||
@@ -1383,35 +1449,48 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
#if PLATFORM(DOM)
|
||||
|
||||
var inputElement = [self _inputElement];
|
||||
|
||||
try
|
||||
if (![self isEditable])
|
||||
{
|
||||
if ([inputElement.selectionStart isKindOfClass:CPNumber])
|
||||
{
|
||||
inputElement.selectionStart = aRange.location;
|
||||
inputElement.selectionEnd = CPMaxRange(aRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
// browsers which don't support selectionStart/selectionEnd (aka IE).
|
||||
var theDocument = inputElement.ownerDocument || inputElement.document,
|
||||
existingRange = theDocument.selection.createRange(),
|
||||
range = inputElement.createTextRange();
|
||||
// No input element - selectable text field only.
|
||||
var contentView = [self layoutEphemeralSubviewNamed:@"content-view"
|
||||
positioned:CPWindowAbove
|
||||
relativeToEphemeralSubviewNamed:@"bezel-view"];
|
||||
|
||||
if (range.inRange(existingRange))
|
||||
if (contentView)
|
||||
[contentView setSelectedRange:aRange];
|
||||
}
|
||||
else
|
||||
{
|
||||
// Input element
|
||||
var inputElement = [self _inputElement];
|
||||
|
||||
try
|
||||
{
|
||||
if ([inputElement.selectionStart isKindOfClass:CPNumber])
|
||||
{
|
||||
range.collapse(true);
|
||||
range.move('character', aRange.location);
|
||||
range.moveEnd('character', aRange.length);
|
||||
range.select();
|
||||
inputElement.selectionStart = aRange.location;
|
||||
inputElement.selectionEnd = CPMaxRange(aRange);
|
||||
}
|
||||
else
|
||||
{
|
||||
// browsers which don't support selectionStart/selectionEnd (aka IE).
|
||||
var theDocument = inputElement.ownerDocument || inputElement.document,
|
||||
existingRange = theDocument.selection.createRange(),
|
||||
range = inputElement.createTextRange();
|
||||
|
||||
if (range.inRange(existingRange))
|
||||
{
|
||||
range.collapse(true);
|
||||
range.move('character', aRange.location);
|
||||
range.moveEnd('character', aRange.length);
|
||||
range.select();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1422,6 +1501,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
- (void)deleteBackward:(id)sender
|
||||
{
|
||||
if (!([self isEnabled] && [self isEditable]))
|
||||
return;
|
||||
|
||||
var selectedRange = [self selectedRange];
|
||||
|
||||
if (selectedRange.length < 2)
|
||||
@@ -1432,8 +1514,9 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
|
||||
var newValue = [_stringValue stringByReplacingCharactersInRange:selectedRange withString:""];
|
||||
|
||||
[self setStringValue:newValue];
|
||||
[self _setStringValue:newValue];
|
||||
[self setSelectedRange:CPMakeRange(selectedRange.location, 0)];
|
||||
[self _didEdit];
|
||||
}
|
||||
|
||||
#pragma mark Setting the Delegate
|
||||
@@ -1614,7 +1697,7 @@ CPTextFieldStatePlaceholder = CPThemeState("placeholder");
|
||||
{
|
||||
[super viewDidUnhide];
|
||||
|
||||
if ([[self window] firstResponder] === self)
|
||||
if ([self isEditable] && [[self window] firstResponder] === self)
|
||||
[self _becomeFirstKeyResponder];
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ var CANVAS_LINECAP_TABLE = [ "butt", "round", "square" ],
|
||||
#define _CGContextFillRectCanvas(aContext, aRect) aContext.fillRect(CGRectGetMinX(aRect), CGRectGetMinY(aRect), CGRectGetWidth(aRect), CGRectGetHeight(aRect))
|
||||
#define _CGContextClipCanvas(aContext) aContext.clip()
|
||||
|
||||
// In Cocoa, all primitives excepts rects cannot be added to the context's path
|
||||
// In Cocoa, all primitives excepts rects and arcs cannot be added to the context's path
|
||||
// until a move to point has been done, because an empty path has no current point.
|
||||
var hasPath = function(aContext, methodName)
|
||||
{
|
||||
@@ -113,12 +113,12 @@ function CGContextSetBlendMode(aContext, aBlendMode)
|
||||
|
||||
function CGContextAddArc(aContext, x, y, radius, startAngle, endAngle, clockwise)
|
||||
{
|
||||
if (!hasPath(aContext, "CGContextAddArc"))
|
||||
return;
|
||||
|
||||
// Despite the documentation saying otherwise, the last parameter is anti-clockwise not clockwise.
|
||||
// http://developer.mozilla.org/en/docs/Canvas_tutorial:Drawing_shapes#Arcs
|
||||
_CGContextAddArcCanvas(aContext, x, y, radius, startAngle, endAngle, !clockwise);
|
||||
|
||||
// AddArc implicitly starts a path
|
||||
aContext.hasPath = YES;
|
||||
}
|
||||
|
||||
function CGContextAddArcToPoint(aContext, x1, y1, x2, y2, radius)
|
||||
|
||||
@@ -991,15 +991,13 @@ var resizeTimer = nil;
|
||||
windowCount = windows.length;
|
||||
|
||||
while (windowCount--)
|
||||
{
|
||||
[windows[windowCount] resizeWithOldPlatformWindowSize:oldSize];
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidChangeScreenParametersNotification
|
||||
object:CPApp
|
||||
userInfo:nil];
|
||||
}
|
||||
}
|
||||
|
||||
[[CPNotificationCenter defaultCenter] postNotificationName:CPApplicationDidChangeScreenParametersNotification
|
||||
object:CPApp
|
||||
userInfo:nil];
|
||||
|
||||
//window.liveResize = NO;
|
||||
|
||||
[[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode];
|
||||
@@ -1504,6 +1502,44 @@ var resizeTimer = nil;
|
||||
return theWindow;
|
||||
}
|
||||
|
||||
/*! @ignore Return the selected text in the DOM window if known. */
|
||||
- (CPString)_selectedText
|
||||
{
|
||||
if (_DOMWindow.getSelection)
|
||||
return "" + _DOMWindow.getSelection();
|
||||
else if (_DOMWindow.document.getSelection)
|
||||
return "" + _DOMWindow.document.getSelection();
|
||||
else if (_DOMWindow.selection)
|
||||
return "" + _DOMWindow.selection.createRange().text;
|
||||
else
|
||||
return nil;
|
||||
}
|
||||
|
||||
/*!
|
||||
Set the text selection range to the given range within the given element, which must be a child of
|
||||
this DOM window.
|
||||
*/
|
||||
- (void)setSelectedRange:(CPRange)aRange inElement:(DOMElement)anElement
|
||||
{
|
||||
if (_DOMWindow.getSelection())
|
||||
{
|
||||
var domRange = _DOMWindow.document.createRange();
|
||||
domRange.setStart(anElement.childNodes[0], aRange.location);
|
||||
domRange.setEnd(anElement.childNodes[0], CPMaxRange(aRange));
|
||||
_DOMWindow.getSelection().removeAllRanges();
|
||||
_DOMWindow.getSelection().addRange(domRange);
|
||||
}
|
||||
else if (_DOMWindow.document.selection)
|
||||
{
|
||||
var domRange = _DOMWindow.document.body.createTextRange();
|
||||
domRange.moveToElementText(anElement);
|
||||
domRange.collapse(true);
|
||||
domRange.moveStart('character', aRange.location);
|
||||
domRange.moveEnd('character', aRange.length);
|
||||
domRange.select();
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
When using command (mac) or control (windows), keys are propagated to the browser by default.
|
||||
To prevent a character key from propagating (to prevent its default action, and instead use it
|
||||
|
||||
@@ -802,4 +802,11 @@ var _CPimageAndTextViewFrameSizeChangedFlag = 1 << 0,
|
||||
[super setFrameSize:aSize];
|
||||
}
|
||||
|
||||
- (void)setSelectedRange:(CPRange)aRange
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
[[[self window] platformWindow] setSelectedRange:aRange inElement:_DOMTextElement];
|
||||
#endif
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
@outlet CPWindow theWindow;
|
||||
@outlet CPCollectionView aCollectionView;
|
||||
@outlet CPArrayController anArrayController;
|
||||
@outlet CPTextField selectableTextField;
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(CPNotification)aNotification
|
||||
@@ -30,6 +31,8 @@
|
||||
|
||||
[anArrayController setContent:@[@"Cat", @"Rabbit", @"Dinosaur", anImage]];
|
||||
|
||||
[selectableTextField setStringValue:@"Lion"];
|
||||
|
||||
[theWindow setFullPlatformWindow:YES];
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -645,7 +645,7 @@
|
||||
<object class="NSWindowTemplate" id="972006081">
|
||||
<int key="NSWindowStyleMask">7</int>
|
||||
<int key="NSWindowBacking">2</int>
|
||||
<string key="NSWindowRect">{{335, 390}, {791, 386}}</string>
|
||||
<string key="NSWindowRect">{{335, 390}, {791, 447}}</string>
|
||||
<int key="NSWTFlags">1946157056</int>
|
||||
<string key="NSWindowTitle">Window</string>
|
||||
<string key="NSWindowClass">NSWindow</string>
|
||||
@@ -659,7 +659,7 @@
|
||||
<object class="NSTextField" id="534430937">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{17, 349}, {237, 17}}</string>
|
||||
<string key="NSFrame">{{17, 410}, {237, 17}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="492282826"/>
|
||||
@@ -763,7 +763,7 @@
|
||||
<string key="NSFrame">{{1, 144}, {233, 15}}</string>
|
||||
<reference key="NSSuperview" ref="492282826"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="646514202"/>
|
||||
<reference key="NSNextKeyView" ref="939393406"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:91</string>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
<int key="NSsFlags">1</int>
|
||||
@@ -772,7 +772,7 @@
|
||||
<double key="NSPercent">0.63157892227172852</double>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{20, 214}, {751, 127}}</string>
|
||||
<string key="NSFrame">{{20, 275}, {751, 127}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="205651234"/>
|
||||
@@ -801,16 +801,17 @@
|
||||
<object class="NSMutableString" key="NSContents">
|
||||
<bytes key="NS.bytes">SW5zdHJ1Y3Rpb25zOgoKMS4gU2VsZWN0IHRleHQgaXRlbXMgaW4gdGhlIENvbGxlY3Rpb24gVmlldyBv
|
||||
ciB0aGUgVGV4dCBGaWVsZCBhbmQgY29weSBpdCB0byB0aGUgc3lzdGVtIGNsaXBib2FyZCAoQ21kLUMg
|
||||
b24gdGhlIE1hYywgQ3RybC1DIG9uIHRoZSBQQykuCjIuIE9wZW4gdGhpcyBhcHBsaWNhdGlvbiBpbiBh
|
||||
IGRpZmZlcmVudCBicm93c2VyIHdpbmRvdywgb3IgZXZlbiBhIGRpZmZlcmVudCBicm93c2VyLiBZb3Ug
|
||||
Y2FuIHRlc3QgY29weWluZyBmcm9tIEZpcmVmb3ggdG8gQ2hyb21lLCBTYWZhcmkgdG8gSW50ZXJuZXQg
|
||||
RXhwbG9yZXIgb3IgdmljZSB2ZXJzYSBhbmQgc28gb24uCjMuIFBhc3RlIGludG8gdGhlIENvbGxlY3Rp
|
||||
b24gVmlldyBvciBUZXh0IEZpZWxkIG9mIHRoZSBkZXN0aW5hdGlvbiBhbmQgdmVyaWZ5IHlvdXIgbWF0
|
||||
ZXJpYWwgdHJhbnNmZXJyZWQgY29ycmVjdGx5Lgo0LiBJdCBpcyBub3QgY3VycmVudGx5IHBvc3NpYmxl
|
||||
IHRvIGNvcHkgb3IgcGFzdGUgaW1hZ2VzIGJldHdlZW4gYnJvd3NlcnMuIFVzaW5nIHRoZSBDYXBwdWNj
|
||||
aW5vIG1lbnVzIG9ubHksIHlvdSBjYW4gY29weSwgY3V0IG9yIHBhc3RlIHRoZSBpbWFnZSBpdGVtIHdp
|
||||
dGhpbiB0aGlzIGFwcCBpbiB0aGlzIGJyb3dzZXIgd2luZG93IChlLmcuIHRvIGFuZCBmcm9tIHRoZSBz
|
||||
YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
b24gdGhlIE1hYywgQ3RybC1DIG9uIHRoZSBQQykuIEl0J3MgYWxzbyBwb3NzaWJsZSB0byBzZWxlY3Qg
|
||||
dGV4dCBmcm9tICJhIGxhYmVsIHdpdGggc2VsZWN0YWJsZSB0ZXh0IiBhbmQgIm5vbi1lZGl0YWJsZSBm
|
||||
aWVsZCIuCjIuIE9wZW4gdGhpcyBhcHBsaWNhdGlvbiBpbiBhIGRpZmZlcmVudCBicm93c2VyIHdpbmRv
|
||||
dywgb3IgZXZlbiBhIGRpZmZlcmVudCBicm93c2VyLiBZb3UgY2FuIHRlc3QgY29weWluZyBmcm9tIEZp
|
||||
cmVmb3ggdG8gQ2hyb21lLCBTYWZhcmkgdG8gSW50ZXJuZXQgRXhwbG9yZXIgb3IgdmljZSB2ZXJzYSBh
|
||||
bmQgc28gb24uCjMuIFBhc3RlIGludG8gdGhlIENvbGxlY3Rpb24gVmlldyBvciBUZXh0IEZpZWxkIG9m
|
||||
IHRoZSBkZXN0aW5hdGlvbiBhbmQgdmVyaWZ5IHlvdXIgbWF0ZXJpYWwgdHJhbnNmZXJyZWQgY29ycmVj
|
||||
dGx5Lgo0LiBJdCBpcyBub3QgY3VycmVudGx5IHBvc3NpYmxlIHRvIGNvcHkgb3IgcGFzdGUgaW1hZ2Vz
|
||||
IGJldHdlZW4gYnJvd3NlcnMuIFVzaW5nIHRoZSBDYXBwdWNjaW5vIG1lbnVzIG9ubHksIHlvdSBjYW4g
|
||||
Y29weSwgY3V0IG9yIHBhc3RlIHRoZSBpbWFnZSBpdGVtIHdpdGhpbiB0aGlzIGFwcCBpbiB0aGlzIGJy
|
||||
b3dzZXIgd2luZG93IChlLmcuIHRvIGFuZCBmcm9tIHRoZSBzYW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
</object>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
@@ -828,10 +829,10 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<object class="NSTextField" id="131499969">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">290</int>
|
||||
<string key="NSFrame">{{162, 186}, {609, 22}}</string>
|
||||
<string key="NSFrame">{{159, 220}, {609, 22}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="647555975"/>
|
||||
<reference key="NSNextKeyView" ref="710607803"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="264543275">
|
||||
@@ -842,7 +843,7 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<string key="NSCellIdentifier">_NS:9</string>
|
||||
<reference key="NSControlView" ref="131499969"/>
|
||||
<bool key="NSDrawsBackground">YES</bool>
|
||||
<object class="NSColor" key="NSBackgroundColor">
|
||||
<object class="NSColor" key="NSBackgroundColor" id="491527331">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">textBackgroundColor</string>
|
||||
@@ -851,7 +852,7 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<bytes key="NSWhite">MQA</bytes>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSColor" key="NSTextColor">
|
||||
<object class="NSColor" key="NSTextColor" id="812820178">
|
||||
<int key="NSColorSpace">6</int>
|
||||
<string key="NSCatalogName">System</string>
|
||||
<string key="NSColorName">textColor</string>
|
||||
@@ -863,7 +864,7 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<object class="NSTextField" id="646514202">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{22, 189}, {135, 17}}</string>
|
||||
<string key="NSFrame">{{19, 223}, {135, 17}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="131499969"/>
|
||||
@@ -881,8 +882,72 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
</object>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
</object>
|
||||
<object class="NSTextField" id="939393406">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">288</int>
|
||||
<string key="NSFrame">{{17, 250}, {757, 17}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="646514202"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1535</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="192842169">
|
||||
<int key="NSCellFlags">70254657</int>
|
||||
<int key="NSCellFlags2">272630784</int>
|
||||
<string key="NSContents">A label with selectable text.</string>
|
||||
<reference key="NSSupport" ref="668931703"/>
|
||||
<string key="NSCellIdentifier">_NS:1535</string>
|
||||
<reference key="NSControlView" ref="939393406"/>
|
||||
<reference key="NSBackgroundColor" ref="815515125"/>
|
||||
<reference key="NSTextColor" ref="618666579"/>
|
||||
</object>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
</object>
|
||||
<object class="NSTextField" id="710607803">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">292</int>
|
||||
<string key="NSFrame">{{19, 191}, {135, 17}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="405018315"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:1535</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="609292086">
|
||||
<int key="NSCellFlags">68157504</int>
|
||||
<int key="NSCellFlags2">71304192</int>
|
||||
<string key="NSContents">Non-editable Field:</string>
|
||||
<reference key="NSSupport" ref="668931703"/>
|
||||
<string key="NSCellIdentifier">_NS:1535</string>
|
||||
<reference key="NSControlView" ref="710607803"/>
|
||||
<reference key="NSBackgroundColor" ref="815515125"/>
|
||||
<reference key="NSTextColor" ref="618666579"/>
|
||||
</object>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
</object>
|
||||
<object class="NSTextField" id="405018315">
|
||||
<reference key="NSNextResponder" ref="439893737"/>
|
||||
<int key="NSvFlags">290</int>
|
||||
<string key="NSFrame">{{159, 188}, {609, 22}}</string>
|
||||
<reference key="NSSuperview" ref="439893737"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="647555975"/>
|
||||
<string key="NSReuseIdentifierKey">_NS:9</string>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSTextFieldCell" key="NSCell" id="181099906">
|
||||
<int key="NSCellFlags">-2073034687</int>
|
||||
<int key="NSCellFlags2">272630784</int>
|
||||
<string key="NSContents"/>
|
||||
<reference key="NSSupport" ref="668931703"/>
|
||||
<string key="NSCellIdentifier">_NS:9</string>
|
||||
<reference key="NSControlView" ref="405018315"/>
|
||||
<bool key="NSDrawsBackground">YES</bool>
|
||||
<reference key="NSBackgroundColor" ref="491527331"/>
|
||||
<reference key="NSTextColor" ref="812820178"/>
|
||||
</object>
|
||||
<bool key="NSAllowsLogicalLayoutDirection">NO</bool>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrameSize">{791, 386}</string>
|
||||
<string key="NSFrameSize">{791, 447}</string>
|
||||
<reference key="NSSuperview"/>
|
||||
<reference key="NSWindow"/>
|
||||
<reference key="NSNextKeyView" ref="534430937"/>
|
||||
@@ -1269,6 +1334,14 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
</object>
|
||||
<int key="connectionID">479</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">selectableTextField</string>
|
||||
<reference key="source" ref="635946545"/>
|
||||
<reference key="destination" ref="405018315"/>
|
||||
</object>
|
||||
<int key="connectionID">503</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">itemPrototype</string>
|
||||
@@ -1845,9 +1918,12 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="534430937"/>
|
||||
<reference ref="492282826"/>
|
||||
<reference ref="939393406"/>
|
||||
<reference ref="647555975"/>
|
||||
<reference ref="646514202"/>
|
||||
<reference ref="131499969"/>
|
||||
<reference ref="646514202"/>
|
||||
<reference ref="710607803"/>
|
||||
<reference ref="405018315"/>
|
||||
</object>
|
||||
<reference key="parent" ref="972006081"/>
|
||||
</object>
|
||||
@@ -1986,6 +2062,48 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<reference key="object" ref="1014031390"/>
|
||||
<reference key="parent" ref="503039080"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">497</int>
|
||||
<reference key="object" ref="939393406"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="192842169"/>
|
||||
</object>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">498</int>
|
||||
<reference key="object" ref="192842169"/>
|
||||
<reference key="parent" ref="939393406"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">499</int>
|
||||
<reference key="object" ref="710607803"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="609292086"/>
|
||||
</object>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">500</int>
|
||||
<reference key="object" ref="609292086"/>
|
||||
<reference key="parent" ref="710607803"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">501</int>
|
||||
<reference key="object" ref="405018315"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="181099906"/>
|
||||
</object>
|
||||
<reference key="parent" ref="439893737"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">502</int>
|
||||
<reference key="object" ref="181099906"/>
|
||||
<reference key="parent" ref="405018315"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -2075,7 +2193,13 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<string>492.IBPluginDependency</string>
|
||||
<string>493.IBPluginDependency</string>
|
||||
<string>494.IBPluginDependency</string>
|
||||
<string>497.IBPluginDependency</string>
|
||||
<string>498.IBPluginDependency</string>
|
||||
<string>499.IBPluginDependency</string>
|
||||
<string>5.IBPluginDependency</string>
|
||||
<string>500.IBPluginDependency</string>
|
||||
<string>501.IBPluginDependency</string>
|
||||
<string>502.IBPluginDependency</string>
|
||||
<string>56.IBPluginDependency</string>
|
||||
<string>57.IBPluginDependency</string>
|
||||
<string>58.IBPluginDependency</string>
|
||||
@@ -2212,6 +2336,12 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="unlocalizedProperties">
|
||||
@@ -2226,7 +2356,7 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<reference key="dict.values" ref="0"/>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">496</int>
|
||||
<int key="maxID">503</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -2240,12 +2370,14 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>aCollectionView</string>
|
||||
<string>anArrayController</string>
|
||||
<string>selectableTextField</string>
|
||||
<string>theWindow</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSCollectionView</string>
|
||||
<string>NSArrayController</string>
|
||||
<string>NSTextField</string>
|
||||
<string>NSWindow</string>
|
||||
</object>
|
||||
</object>
|
||||
@@ -2255,6 +2387,7 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>aCollectionView</string>
|
||||
<string>anArrayController</string>
|
||||
<string>selectableTextField</string>
|
||||
<string>theWindow</string>
|
||||
</object>
|
||||
<object class="NSArray" key="dict.values">
|
||||
@@ -2267,6 +2400,10 @@ YW1lIGNvbGxlY3Rpb24gdmlldykuA</bytes>
|
||||
<string key="name">anArrayController</string>
|
||||
<string key="candidateClassName">NSArrayController</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">selectableTextField</string>
|
||||
<string key="candidateClassName">NSTextField</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">theWindow</string>
|
||||
<string key="candidateClassName">NSWindow</string>
|
||||
|
||||
Reference in New Issue
Block a user