Renamed non-primary button events/handlers

This commit is contained in:
Mark Salsbery 2015-01-12 11:02:54 -08:00
parent becd11b6ce
commit 755854d3f7
3 changed files with 105 additions and 105 deletions

View File

@ -72,11 +72,11 @@
* An optional handler for pointer exit. * An optional handler for pointer exit.
* @param {OpenSeadragon.EventHandler} [options.pressHandler=null] * @param {OpenSeadragon.EventHandler} [options.pressHandler=null]
* An optional handler for pointer press. * An optional handler for pointer press.
* @param {OpenSeadragon.EventHandler} [options.auxPressHandler=null] * @param {OpenSeadragon.EventHandler} [options.nonPrimaryPressHandler=null]
* An optional handler for pointer non-primary button press. * An optional handler for pointer non-primary button press.
* @param {OpenSeadragon.EventHandler} [options.releaseHandler=null] * @param {OpenSeadragon.EventHandler} [options.releaseHandler=null]
* An optional handler for pointer release. * An optional handler for pointer release.
* @param {OpenSeadragon.EventHandler} [options.auxReleaseHandler=null] * @param {OpenSeadragon.EventHandler} [options.nonPrimaryReleaseHandler=null]
* An optional handler for pointer non-primary button release. * An optional handler for pointer non-primary button release.
* @param {OpenSeadragon.EventHandler} [options.moveHandler=null] * @param {OpenSeadragon.EventHandler} [options.moveHandler=null]
* An optional handler for pointer move. * An optional handler for pointer move.
@ -148,26 +148,26 @@
* @memberof OpenSeadragon.MouseTracker# * @memberof OpenSeadragon.MouseTracker#
*/ */
this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold; this.dblClickDistThreshold = options.dblClickDistThreshold || $.DEFAULT_SETTINGS.dblClickDistThreshold;
this.userData = options.userData || null; this.userData = options.userData || null;
this.stopDelay = options.stopDelay || 50; this.stopDelay = options.stopDelay || 50;
this.enterHandler = options.enterHandler || null; this.enterHandler = options.enterHandler || null;
this.exitHandler = options.exitHandler || null; this.exitHandler = options.exitHandler || null;
this.pressHandler = options.pressHandler || null; this.pressHandler = options.pressHandler || null;
this.auxPressHandler = options.auxPressHandler || null; this.nonPrimaryPressHandler = options.nonPrimaryPressHandler || null;
this.releaseHandler = options.releaseHandler || null; this.releaseHandler = options.releaseHandler || null;
this.auxReleaseHandler = options.auxReleaseHandler || null; this.nonPrimaryReleaseHandler = options.nonPrimaryReleaseHandler || null;
this.moveHandler = options.moveHandler || null; this.moveHandler = options.moveHandler || null;
this.scrollHandler = options.scrollHandler || null; this.scrollHandler = options.scrollHandler || null;
this.clickHandler = options.clickHandler || null; this.clickHandler = options.clickHandler || null;
this.dblClickHandler = options.dblClickHandler || null; this.dblClickHandler = options.dblClickHandler || null;
this.dragHandler = options.dragHandler || null; this.dragHandler = options.dragHandler || null;
this.dragEndHandler = options.dragEndHandler || null; this.dragEndHandler = options.dragEndHandler || null;
this.pinchHandler = options.pinchHandler || null; this.pinchHandler = options.pinchHandler || null;
this.stopHandler = options.stopHandler || null; this.stopHandler = options.stopHandler || null;
this.keyHandler = options.keyHandler || null; this.keyHandler = options.keyHandler || null;
this.focusHandler = options.focusHandler || null; this.focusHandler = options.focusHandler || null;
this.blurHandler = options.blurHandler || null; this.blurHandler = options.blurHandler || null;
//Store private properties in a scope sealed hash map //Store private properties in a scope sealed hash map
var _this = this; var _this = this;
@ -424,7 +424,7 @@
* @param {Object} event.userData * @param {Object} event.userData
* Arbitrary user-defined object. * Arbitrary user-defined object.
*/ */
auxPressHandler: function () { }, nonPrimaryPressHandler: function () { },
/** /**
* Implement or assign implementation to these handlers during or after * Implement or assign implementation to these handlers during or after
@ -482,7 +482,7 @@
* @param {Object} event.userData * @param {Object} event.userData
* Arbitrary user-defined object. * Arbitrary user-defined object.
*/ */
auxReleaseHandler: function () { }, nonPrimaryReleaseHandler: function () { },
/** /**
* Implement or assign implementation to these handlers during or after * Implement or assign implementation to these handlers during or after
@ -2494,8 +2494,8 @@
// Only capture and track primary button, pen, and touch contacts // Only capture and track primary button, pen, and touch contacts
if ( buttonChanged !== 0 ) { if ( buttonChanged !== 0 ) {
// Aux Press // Aux Press
if ( tracker.auxPressHandler ) { if ( tracker.nonPrimaryPressHandler ) {
propagate = tracker.auxPressHandler( propagate = tracker.nonPrimaryPressHandler(
{ {
eventSource: tracker, eventSource: tracker,
pointerType: gPoints[ 0 ].type, pointerType: gPoints[ 0 ].type,
@ -2662,8 +2662,8 @@
// Only capture and track primary button, pen, and touch contacts // Only capture and track primary button, pen, and touch contacts
if ( buttonChanged !== 0 ) { if ( buttonChanged !== 0 ) {
// Aux Release // Aux Release
if ( tracker.auxReleaseHandler ) { if ( tracker.nonPrimaryReleaseHandler ) {
propagate = tracker.auxReleaseHandler( propagate = tracker.nonPrimaryReleaseHandler(
{ {
eventSource: tracker, eventSource: tracker,
pointerType: gPoints[ 0 ].type, pointerType: gPoints[ 0 ].type,

View File

@ -380,20 +380,20 @@ $.Viewer = function( options ) {
this.innerTracker = new $.MouseTracker({ this.innerTracker = new $.MouseTracker({
element: this.canvas, element: this.canvas,
clickTimeThreshold: this.clickTimeThreshold, clickTimeThreshold: this.clickTimeThreshold,
clickDistThreshold: this.clickDistThreshold, clickDistThreshold: this.clickDistThreshold,
dblClickTimeThreshold: this.dblClickTimeThreshold, dblClickTimeThreshold: this.dblClickTimeThreshold,
dblClickDistThreshold: this.dblClickDistThreshold, dblClickDistThreshold: this.dblClickDistThreshold,
clickHandler: $.delegate( this, onCanvasClick ), clickHandler: $.delegate( this, onCanvasClick ),
dblClickHandler: $.delegate( this, onCanvasDblClick ), dblClickHandler: $.delegate( this, onCanvasDblClick ),
dragHandler: $.delegate( this, onCanvasDrag ), dragHandler: $.delegate( this, onCanvasDrag ),
dragEndHandler: $.delegate( this, onCanvasDragEnd ), dragEndHandler: $.delegate( this, onCanvasDragEnd ),
releaseHandler: $.delegate( this, onCanvasRelease ), releaseHandler: $.delegate( this, onCanvasRelease ),
auxPressHandler: $.delegate( this, onCanvasAuxPress ), nonPrimaryPressHandler: $.delegate( this, onCanvasNonPrimaryPress ),
auxReleaseHandler: $.delegate( this, onCanvasAuxRelease ), nonPrimaryReleaseHandler: $.delegate( this, onCanvasNonPrimaryRelease ),
scrollHandler: $.delegate( this, onCanvasScroll ), scrollHandler: $.delegate( this, onCanvasScroll ),
pinchHandler: $.delegate( this, onCanvasPinch ) pinchHandler: $.delegate( this, onCanvasPinch )
}).setTracking( this.mouseNavEnabled ? true : false ); // default state }).setTracking( this.mouseNavEnabled ? true : false ); // default state
this.outerTracker = new $.MouseTracker({ this.outerTracker = new $.MouseTracker({
@ -2446,11 +2446,11 @@ function onCanvasRelease( event ) {
}); });
} }
function onCanvasAuxPress( event ) { function onCanvasNonPrimaryPress( event ) {
/** /**
* Raised when any non-primary pointer button is pressed on the {@link OpenSeadragon.Viewer#canvas} element. * Raised when any non-primary pointer button is pressed on the {@link OpenSeadragon.Viewer#canvas} element.
* *
* @event canvas-aux-press * @event canvas-nonprimary-press
* @memberof OpenSeadragon.Viewer * @memberof OpenSeadragon.Viewer
* @type {object} * @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event. * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
@ -2464,7 +2464,7 @@ function onCanvasAuxPress( event ) {
* @property {Object} originalEvent - The original DOM event. * @property {Object} originalEvent - The original DOM event.
* @property {?Object} userData - Arbitrary subscriber-defined object. * @property {?Object} userData - Arbitrary subscriber-defined object.
*/ */
this.raiseEvent( 'canvas-aux-press', { this.raiseEvent( 'canvas-nonprimary-press', {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
pointerType: event.pointerType, pointerType: event.pointerType,
@ -2474,11 +2474,11 @@ function onCanvasAuxPress( event ) {
}); });
} }
function onCanvasAuxRelease( event ) { function onCanvasNonPrimaryRelease( event ) {
/** /**
* Raised when any non-primary pointer button is released on the {@link OpenSeadragon.Viewer#canvas} element. * Raised when any non-primary pointer button is released on the {@link OpenSeadragon.Viewer#canvas} element.
* *
* @event canvas-aux-release * @event canvas-nonprimary-release
* @memberof OpenSeadragon.Viewer * @memberof OpenSeadragon.Viewer
* @type {object} * @type {object}
* @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event. * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised this event.
@ -2492,7 +2492,7 @@ function onCanvasAuxRelease( event ) {
* @property {Object} originalEvent - The original DOM event. * @property {Object} originalEvent - The original DOM event.
* @property {?Object} userData - Arbitrary subscriber-defined object. * @property {?Object} userData - Arbitrary subscriber-defined object.
*/ */
this.raiseEvent( 'canvas-aux-release', { this.raiseEvent( 'canvas-nonprimary-release', {
tracker: event.eventSource, tracker: event.eventSource,
position: event.position, position: event.position,
pointerType: event.pointerType, pointerType: event.pointerType,

View File

@ -35,8 +35,8 @@
origExitHandler, origExitHandler,
origPressHandler, origPressHandler,
origReleaseHandler, origReleaseHandler,
origAuxPressHandler, origNonPrimaryPressHandler,
origAuxReleaseHandler, origNonPrimaryReleaseHandler,
origMoveHandler, origMoveHandler,
origClickHandler, origClickHandler,
origDblClickHandler, origDblClickHandler,
@ -48,8 +48,8 @@
releaseCount, releaseCount,
rightPressCount, rightPressCount,
rightReleaseCount, rightReleaseCount,
auxPressCount, middlePressCount,
auxReleaseCount, middleReleaseCount,
moveCount, moveCount,
clickCount, clickCount,
dblClickCount, dblClickCount,
@ -100,32 +100,32 @@
return true; return true;
} }
}; };
origAuxPressHandler = tracker.auxPressHandler; origNonPrimaryPressHandler = tracker.nonPrimaryPressHandler;
tracker.auxPressHandler = function ( event ) { tracker.nonPrimaryPressHandler = function ( event ) {
if (event.button === 0) { if (event.button === 0) {
pressCount++; pressCount++;
} else if (event.button === 1) { } else if (event.button === 1) {
auxPressCount++; middlePressCount++;
} else if (event.button === 2) { } else if (event.button === 2) {
rightPressCount++; rightPressCount++;
} }
if (origAuxPressHandler) { if (origNonPrimaryPressHandler) {
return origAuxPressHandler( event ); return origNonPrimaryPressHandler( event );
} else { } else {
return true; return true;
} }
}; };
origAuxReleaseHandler = tracker.auxReleaseHandler; origNonPrimaryReleaseHandler = tracker.nonPrimaryReleaseHandler;
tracker.auxReleaseHandler = function ( event ) { tracker.nonPrimaryReleaseHandler = function ( event ) {
if (event.button === 0) { if (event.button === 0) {
releaseCount++; releaseCount++;
} else if (event.button === 1) { } else if (event.button === 1) {
auxReleaseCount++; middleReleaseCount++;
} else if (event.button === 2) { } else if (event.button === 2) {
rightReleaseCount++; rightReleaseCount++;
} }
if (origAuxReleaseHandler) { if (origNonPrimaryReleaseHandler) {
return origAuxReleaseHandler( event ); return origNonPrimaryReleaseHandler( event );
} else { } else {
return true; return true;
} }
@ -225,14 +225,14 @@
$canvas.simulate( 'mouseup', simEvent ); $canvas.simulate( 'mouseup', simEvent );
}; };
var simulateAuxDown = function (x, y, button) { var simulateNonPrimaryDown = function (x, y, button) {
simEvent.button = button; simEvent.button = button;
simEvent.clientX = offset.left + x; simEvent.clientX = offset.left + x;
simEvent.clientY = offset.top + y; simEvent.clientY = offset.top + y;
$canvas.simulate( 'mousedown', simEvent ); $canvas.simulate( 'mousedown', simEvent );
}; };
var simulateAuxUp = function (x, y, button) { var simulateNonPrimaryUp = function (x, y, button) {
simEvent.button = button; simEvent.button = button;
simEvent.clientX = offset.left + x; simEvent.clientX = offset.left + x;
simEvent.clientY = offset.top + y; simEvent.clientY = offset.top + y;
@ -260,8 +260,8 @@
releaseCount = 0; releaseCount = 0;
rightPressCount = 0; rightPressCount = 0;
rightReleaseCount = 0; rightReleaseCount = 0;
auxPressCount = 0; middlePressCount = 0;
auxReleaseCount = 0; middleReleaseCount = 0;
moveCount = 0; moveCount = 0;
clickCount = 0; clickCount = 0;
dblClickCount = 0; dblClickCount = 0;
@ -289,16 +289,16 @@
equal( releaseCount, expected.releaseCount, expected.description + 'releaseHandler event count matches expected (' + expected.releaseCount + ')' ); equal( releaseCount, expected.releaseCount, expected.description + 'releaseHandler event count matches expected (' + expected.releaseCount + ')' );
} }
if ('rightPressCount' in expected) { if ('rightPressCount' in expected) {
equal( rightPressCount, expected.rightPressCount, expected.description + 'auxPressHandler event count (secondary/right button) matches expected (' + expected.rightPressCount + ')' ); equal( rightPressCount, expected.rightPressCount, expected.description + 'nonPrimaryPressHandler event count (secondary/right button) matches expected (' + expected.rightPressCount + ')' );
} }
if ('rightReleaseCount' in expected) { if ('rightReleaseCount' in expected) {
equal( rightReleaseCount, expected.rightReleaseCount, expected.description + 'auxReleaseHandler event count (secondary/right button) matches expected (' + expected.rightReleaseCount + ')' ); equal( rightReleaseCount, expected.rightReleaseCount, expected.description + 'nonPrimaryReleaseHandler event count (secondary/right button) matches expected (' + expected.rightReleaseCount + ')' );
} }
if ('auxPressCount' in expected) { if ('middlePressCount' in expected) {
equal( auxPressCount, expected.auxPressCount, expected.description + 'auxPressHandler event count (aux/middle button) matches expected (' + expected.auxPressCount + ')' ); equal( middlePressCount, expected.middlePressCount, expected.description + 'nonPrimaryPressHandler event count (aux/middle button) matches expected (' + expected.middlePressCount + ')' );
} }
if ('auxReleaseCount' in expected) { if ('middleReleaseCount' in expected) {
equal( auxReleaseCount, expected.auxReleaseCount, expected.description + 'auxReleaseHandler event count (aux/middle button) matches expected (' + expected.auxReleaseCount + ')' ); equal( middleReleaseCount, expected.middleReleaseCount, expected.description + 'nonPrimaryReleaseHandler event count (aux/middle button) matches expected (' + expected.middleReleaseCount + ')' );
} }
if ('moveCount' in expected) { if ('moveCount' in expected) {
equal( moveCount, expected.moveCount, expected.description + 'moveHandler event count matches expected (' + expected.moveCount + ')' ); equal( moveCount, expected.moveCount, expected.description + 'moveHandler event count matches expected (' + expected.moveCount + ')' );
@ -361,8 +361,8 @@
releaseCount: 1, releaseCount: 1,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 20, moveCount: 20,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -390,8 +390,8 @@
releaseCount: 0, releaseCount: 0,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 20, moveCount: 20,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -417,8 +417,8 @@
releaseCount: 0, releaseCount: 0,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 20, moveCount: 20,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -447,8 +447,8 @@
releaseCount: 2, releaseCount: 2,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 0, moveCount: 0,
clickCount: 2, clickCount: 2,
dblClickCount: 1, dblClickCount: 1,
@ -475,8 +475,8 @@
releaseCount: 1, releaseCount: 1,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 0, moveCount: 0,
clickCount: 1, clickCount: 1,
dblClickCount: 0, dblClickCount: 0,
@ -489,22 +489,22 @@
quickClick: true quickClick: true
}); });
// enter-auxpress-auxrelease-exit (secondary/right click) // enter-nonprimarypress-nonprimaryrelease-exit (secondary/right click)
resetForAssessment(); resetForAssessment();
simulateEnter(0, 0); simulateEnter(0, 0);
simulateAuxDown(0, 0, 2); simulateNonPrimaryDown(0, 0, 2);
simulateAuxUp(0, 0, 2); simulateNonPrimaryUp(0, 0, 2);
simulateLeave(-1, -1); simulateLeave(-1, -1);
assessGestureExpectations({ assessGestureExpectations({
description: 'enter-auxpress-auxrelease-exit (secondary/right click): ', description: 'enter-nonprimarypress-nonprimaryrelease-exit (secondary/right click): ',
enterCount: 1, enterCount: 1,
exitCount: 1, exitCount: 1,
pressCount: 0, pressCount: 0,
releaseCount: 0, releaseCount: 0,
rightPressCount: 1, rightPressCount: 1,
rightReleaseCount: 1, rightReleaseCount: 1,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 0, moveCount: 0,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -517,22 +517,22 @@
//quickClick: true //quickClick: true
}); });
// enter-auxpress-auxrelease-exit (aux/middle click) // enter-nonprimarypress-nonprimaryrelease-exit (aux/middle click)
resetForAssessment(); resetForAssessment();
simulateEnter(0, 0); simulateEnter(0, 0);
simulateAuxDown(0, 0, 1); simulateNonPrimaryDown(0, 0, 1);
simulateAuxUp(0, 0, 1); simulateNonPrimaryUp(0, 0, 1);
simulateLeave(-1, -1); simulateLeave(-1, -1);
assessGestureExpectations({ assessGestureExpectations({
description: 'enter-auxpress-auxrelease-exit (aux/middle click): ', description: 'enter-nonprimarypress-nonprimaryrelease-exit (aux/middle click): ',
enterCount: 1, enterCount: 1,
exitCount: 1, exitCount: 1,
pressCount: 0, pressCount: 0,
releaseCount: 0, releaseCount: 0,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 1, middlePressCount: 1,
auxReleaseCount: 1, middleReleaseCount: 1,
moveCount: 0, moveCount: 0,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -545,24 +545,24 @@
//quickClick: true //quickClick: true
}); });
// enter-auxpress-move-auxrelease-move-exit (secondary/right button drag, release in tracked element) // enter-nonprimarypress-move-nonprimaryrelease-move-exit (secondary/right button drag, release in tracked element)
resetForAssessment(); resetForAssessment();
simulateEnter(0, 0); simulateEnter(0, 0);
simulateAuxDown(0, 0, 2); simulateNonPrimaryDown(0, 0, 2);
simulateMove(1, 1, 100); simulateMove(1, 1, 100);
simulateAuxUp(10, 10, 2); simulateNonPrimaryUp(10, 10, 2);
simulateMove(-1, -1, 100); simulateMove(-1, -1, 100);
simulateLeave(-1, -1); simulateLeave(-1, -1);
assessGestureExpectations({ assessGestureExpectations({
description: 'enter-auxpress-move-auxrelease-move-exit (secondary/right button drag, release in tracked element): ', description: 'enter-nonprimarypress-move-nonprimaryrelease-move-exit (secondary/right button drag, release in tracked element): ',
enterCount: 1, enterCount: 1,
exitCount: 1, exitCount: 1,
pressCount: 0, pressCount: 0,
releaseCount: 0, releaseCount: 0,
rightPressCount: 1, rightPressCount: 1,
rightReleaseCount: 1, rightReleaseCount: 1,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 200, moveCount: 200,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -591,8 +591,8 @@
releaseCount: 1, releaseCount: 1,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 200, moveCount: 200,
clickCount: 1, clickCount: 1,
dblClickCount: 0, dblClickCount: 0,
@ -622,8 +622,8 @@
releaseCount: 1, releaseCount: 1,
rightPressCount: 0, rightPressCount: 0,
rightReleaseCount: 0, rightReleaseCount: 0,
auxPressCount: 0, middlePressCount: 0,
auxReleaseCount: 0, middleReleaseCount: 0,
moveCount: 15, moveCount: 15,
clickCount: 0, clickCount: 0,
dblClickCount: 0, dblClickCount: 0,
@ -652,8 +652,8 @@
// releaseCount: 1, // releaseCount: 1,
// rightPressCount: 0, // rightPressCount: 0,
// rightReleaseCount: 0, // rightReleaseCount: 0,
// auxPressCount: 0, // middlePressCount: 0,
// auxReleaseCount: 0, // middleReleaseCount: 0,
// moveCount: 10, // moveCount: 10,
// clickCount: 0, // clickCount: 0,
// dblClickCount: 0, // dblClickCount: 0,