in src/Clients/Web/winjs/js/winjs.js [33010:33138]
onPointerDown: function ItemEventsHandler_onPointerDown(eventObject) {
_WriteProfilerMark("WinJS.UI._ItemEventsHandler:MSPointerDown,StartTM");
var site = this._site,
touchInput = (eventObject.pointerType === PT_TOUCH),
leftButton,
rightButton;
site.pressedElement = eventObject.target;
if (_WinRT.Windows.UI.Input.PointerPoint) {
// xButton is true when you've x-clicked with a mouse or pen. Otherwise it is false.
var currentPoint = this._getCurrentPoint(eventObject);
var pointProps = currentPoint.properties;
if (!(touchInput || pointProps.isInverted || pointProps.isEraser || pointProps.isMiddleButtonPressed)) {
rightButton = pointProps.isRightButtonPressed;
leftButton = !rightButton && pointProps.isLeftButtonPressed;
} else {
leftButton = rightButton = false;
}
} else {
// xButton is true when you've x-clicked with a mouse. Otherwise it is false.
leftButton = (eventObject.button === _Constants._LEFT_MSPOINTER_BUTTON);
rightButton = (eventObject.button === _Constants._RIGHT_MSPOINTER_BUTTON);
}
this._DragStartBound = this._DragStartBound || this.onDragStart.bind(this);
this._PointerEnterBound = this._PointerEnterBound || this.onPointerEnter.bind(this);
this._PointerLeaveBound = this._PointerLeaveBound || this.onPointerLeave.bind(this);
this._swipeBehaviorState = MSManipulationEventStates.MS_MANIPULATION_STATE_STOPPED;
var swipeEnabled = site.swipeBehavior === _UI.SwipeBehavior.select,
isInteractive = this._isInteractive(eventObject.target),
currentPressedIndex = site.indexForItemElement(eventObject.target),
currentPressedHeaderIndex = site.indexForHeaderElement(eventObject.target),
mustSetCapture = !isInteractive && currentPressedIndex !== _Constants._INVALID_INDEX;
if ((touchInput || leftButton || (this._selectionAllowed() && swipeEnabled && rightButton)) && this._site.pressedEntity.index === _Constants._INVALID_INDEX && !isInteractive) {
if (currentPressedHeaderIndex === _Constants._INVALID_INDEX) {
this._site.pressedEntity = { type: _UI.ObjectType.item, index: currentPressedIndex };
} else {
this._site.pressedEntity = { type: _UI.ObjectType.groupHeader, index: currentPressedHeaderIndex };
}
if (this._site.pressedEntity.index !== _Constants._INVALID_INDEX) {
this._site.pressedPosition = _ElementUtilities._getCursorPos(eventObject);
var allowed = site.verifySelectionAllowed(this._site.pressedEntity);
this._canSelect = allowed.canSelect;
this._canTapSelect = allowed.canTapSelect;
this._swipeBehaviorSelectionChanged = false;
this._selectionHint = null;
if (this._site.pressedEntity.type === _UI.ObjectType.item) {
this._site.pressedItemBox = site.itemBoxAtIndex(this._site.pressedEntity.index);
this._site.pressedContainer = site.containerAtIndex(this._site.pressedEntity.index);
this._site.animatedElement = _BaseUtils.isPhone ? this._site.pressedItemBox : this._site.pressedContainer;
this._site.pressedHeader = null;
this._togglePressed(true, false, eventObject);
this._site.pressedContainer.addEventListener('dragstart', this._DragStartBound);
if (!touchInput) {
// This only works for non touch input because on touch input we set capture which immediately fires the MSPointerOut.
_ElementUtilities._addEventListener(this._site.pressedContainer, 'pointerenter', this._PointerEnterBound, false);
_ElementUtilities._addEventListener(this._site.pressedContainer, 'pointerleave', this._PointerLeaveBound, false);
}
} else {
this._site.pressedHeader = this._site.headerFromElement(eventObject.target);
// Interactions with the headers on phone show an animation
if (_BaseUtils.isPhone) {
this._site.animatedElement = this._site.pressedHeader;
this._togglePressed(true, false, eventObject);
} else {
this._site.pressedItemBox = null;
this._site.pressedContainer = null;
this._site.animatedElement = null;
}
}
if (!this._resetPointerDownStateBound) {
this._resetPointerDownStateBound = this._resetPointerDownStateForPointerId.bind(this);
}
if (!touchInput) {
_ElementUtilities._addEventListener(_Global, "pointerup", this._resetPointerDownStateBound, false);
_ElementUtilities._addEventListener(_Global, "pointercancel", this._resetPointerDownStateBound, false);
}
// The gesture recognizer is used for SRG, which is not supported on Phone
if (this._canSelect && !_BaseUtils.isPhone) {
if (!this._gestureRecognizer) {
this._gestureRecognizer = this._createGestureRecognizer();
}
this._addSelectionHint();
}
this._pointerId = eventObject.pointerId;
this._pointerRightButton = rightButton;
this._pointerTriggeredSRG = false;
if (this._gestureRecognizer && touchInput) {
try {
this._gestureRecognizer.addPointer(this._pointerId);
} catch (e) {
this._gestureRecognizer.stop();
}
}
}
}
if (mustSetCapture) {
if (touchInput) {
try {
// Move pointer capture to avoid hover visual on second finger
_ElementUtilities._setPointerCapture(site.canvasProxy, eventObject.pointerId);
} catch (e) {
_WriteProfilerMark("WinJS.UI._ItemEventsHandler:MSPointerDown,StopTM");
return;
}
}
}
// Once the shift selection pivot is set, it remains the same until the user
// performs a left- or right-click without holding the shift key down.
if (this._site.pressedEntity.type === _UI.ObjectType.item &&
this._selectionAllowed() && this._multiSelection() && // Multi selection enabled
this._site.pressedEntity.index !== _Constants._INVALID_INDEX && // A valid item was clicked
site.selection._getFocused().index !== _Constants._INVALID_INDEX && site.selection._pivot === _Constants._INVALID_INDEX) {
site.selection._pivot = site.selection._getFocused().index;
}
_WriteProfilerMark("WinJS.UI._ItemEventsHandler:MSPointerDown,StopTM");
},