mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Added preventDefault option to MouseTracker.contextMenuHandler and Viewer 'canvas-contextmenu' event args
This commit is contained in:
parent
ab3f49abe3
commit
c38188927e
@ -36,6 +36,7 @@ OPENSEADRAGON CHANGELOG
|
|||||||
* Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery)
|
* Added additional documentation for the zoomPerSecond viewer option (#1872 @msalsbery)
|
||||||
* MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery)
|
* MouseTracker: Per #1863, dropped support for Internet Explorer < 11 (#1872 @msalsbery)
|
||||||
* Fixed simulated drag events in navigator tests (#1949 @msalsbery)
|
* Fixed simulated drag events in navigator tests (#1949 @msalsbery)
|
||||||
|
* Added preventDefault option to MouseTracker.contextMenuHandler and Viewer 'canvas-contextmenu' event args (# @msalsbery)
|
||||||
|
|
||||||
2.4.2:
|
2.4.2:
|
||||||
|
|
||||||
|
@ -280,7 +280,6 @@
|
|||||||
this.dragHandler || this.dragEndHandler ||
|
this.dragHandler || this.dragEndHandler ||
|
||||||
this.pinchHandler );
|
this.pinchHandler );
|
||||||
this.hasScrollHandler = !!this.scrollHandler;
|
this.hasScrollHandler = !!this.scrollHandler;
|
||||||
this.hasContextMenuHandler = !!this.contextMenuHandler;
|
|
||||||
|
|
||||||
if (this.exitHandler) {
|
if (this.exitHandler) {
|
||||||
$.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead.");
|
$.console.error("MouseTracker.exitHandler is deprecated. Use MouseTracker.leaveHandler instead.");
|
||||||
@ -402,6 +401,8 @@
|
|||||||
* The position of the event relative to the tracked element.
|
* The position of the event relative to the tracked element.
|
||||||
* @param {Object} event.originalEvent
|
* @param {Object} event.originalEvent
|
||||||
* The original event object.
|
* The original event object.
|
||||||
|
* @param {Boolean} event.preventDefault
|
||||||
|
* Set to true to prevent the default user-agent's handling of the contextmenu event.
|
||||||
* @param {Object} event.userData
|
* @param {Object} event.userData
|
||||||
* Arbitrary user-defined object.
|
* Arbitrary user-defined object.
|
||||||
*/
|
*/
|
||||||
@ -1942,6 +1943,8 @@
|
|||||||
function onContextMenu( tracker, event ) {
|
function onContextMenu( tracker, event ) {
|
||||||
//$.console.log('contextmenu ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
//$.console.log('contextmenu ' + (tracker.userData ? tracker.userData.toString() : '') + ' ' + (event.target === tracker.element ? 'tracker.element' : ''));
|
||||||
|
|
||||||
|
var eventArgs = null;
|
||||||
|
|
||||||
var eventInfo = {
|
var eventInfo = {
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
eventType: 'contextmenu',
|
eventType: 'contextmenu',
|
||||||
@ -1952,17 +1955,18 @@
|
|||||||
|
|
||||||
// ContextMenu
|
// ContextMenu
|
||||||
if ( tracker.contextMenuHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
if ( tracker.contextMenuHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
||||||
tracker.contextMenuHandler(
|
eventArgs = {
|
||||||
{
|
eventSource: tracker,
|
||||||
eventSource: tracker,
|
position: getPointRelativeToAbsolute( getMouseAbsolute( event ), tracker.element ),
|
||||||
position: getPointRelativeToAbsolute( getMouseAbsolute( event ), tracker.element ),
|
originalEvent: eventInfo.originalEvent,
|
||||||
originalEvent: eventInfo.originalEvent,
|
preventDefault: eventInfo.preventDefault || eventInfo.defaultPrevented,
|
||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
tracker.contextMenuHandler( eventArgs );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
if ( ( eventArgs && eventArgs.preventDefault ) || ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) ) {
|
||||||
$.cancelEvent( event );
|
$.cancelEvent( event );
|
||||||
}
|
}
|
||||||
if ( eventInfo.stopPropagation ) {
|
if ( eventInfo.stopPropagation ) {
|
||||||
@ -2810,7 +2814,7 @@
|
|||||||
case 'pointerdown':
|
case 'pointerdown':
|
||||||
eventInfo.isStopable = true;
|
eventInfo.isStopable = true;
|
||||||
eventInfo.isCancelable = true;
|
eventInfo.isCancelable = true;
|
||||||
eventInfo.preventDefault = false;//tracker.hasGestureHandlers;
|
eventInfo.preventDefault = false; // updatePointerDown() may set true (tracker.hasGestureHandlers)
|
||||||
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
eventInfo.preventGesture = !tracker.hasGestureHandlers;
|
||||||
eventInfo.stopPropagation = false;
|
eventInfo.stopPropagation = false;
|
||||||
break;
|
break;
|
||||||
@ -2824,7 +2828,7 @@
|
|||||||
case 'wheel':
|
case 'wheel':
|
||||||
eventInfo.isStopable = true;
|
eventInfo.isStopable = true;
|
||||||
eventInfo.isCancelable = true;
|
eventInfo.isCancelable = true;
|
||||||
eventInfo.preventDefault = false;//tracker.hasScrollHandler;
|
eventInfo.preventDefault = false; // handleWheelEvent() may set true (tracker.hasScrollHandler)
|
||||||
eventInfo.preventGesture = !tracker.hasScrollHandler;
|
eventInfo.preventGesture = !tracker.hasScrollHandler;
|
||||||
eventInfo.stopPropagation = false;
|
eventInfo.stopPropagation = false;
|
||||||
break;
|
break;
|
||||||
@ -2854,8 +2858,8 @@
|
|||||||
case 'contextmenu':
|
case 'contextmenu':
|
||||||
eventInfo.isStopable = true;
|
eventInfo.isStopable = true;
|
||||||
eventInfo.isCancelable = true;
|
eventInfo.isCancelable = true;
|
||||||
eventInfo.preventDefault = false;//tracker.hasContextMenuHandler;
|
eventInfo.preventDefault = false;
|
||||||
eventInfo.preventGesture = true;//!tracker.hasContextMenuHandler;
|
eventInfo.preventGesture = false;
|
||||||
eventInfo.stopPropagation = false;
|
eventInfo.stopPropagation = false;
|
||||||
break;
|
break;
|
||||||
case 'pointerenter':
|
case 'pointerenter':
|
||||||
|
@ -2546,6 +2546,13 @@ function onBlur(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasContextMenu( event ) {
|
function onCanvasContextMenu( event ) {
|
||||||
|
var eventArgs = {
|
||||||
|
tracker: event.eventSource,
|
||||||
|
position: event.position,
|
||||||
|
originalEvent: event.originalEvent,
|
||||||
|
preventDefault: event.preventDefault
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Raised when a contextmenu event occurs in the {@link OpenSeadragon.Viewer#canvas} element.
|
* Raised when a contextmenu event occurs in the {@link OpenSeadragon.Viewer#canvas} element.
|
||||||
*
|
*
|
||||||
@ -2556,13 +2563,12 @@ function onCanvasContextMenu( event ) {
|
|||||||
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
* @property {OpenSeadragon.MouseTracker} tracker - A reference to the MouseTracker which originated this event.
|
||||||
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
* @property {OpenSeadragon.Point} position - The position of the event relative to the tracked element.
|
||||||
* @property {Object} originalEvent - The original DOM event.
|
* @property {Object} originalEvent - The original DOM event.
|
||||||
|
* @property {Boolean} preventDefault - Set to true to prevent the default user-agent's handling of the contextmenu event.
|
||||||
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
* @property {?Object} userData - Arbitrary subscriber-defined object.
|
||||||
*/
|
*/
|
||||||
this.raiseEvent( 'canvas-contextmenu', {
|
this.raiseEvent( 'canvas-contextmenu', eventArgs );
|
||||||
tracker: event.eventSource,
|
|
||||||
position: event.position,
|
event.preventDefault = eventArgs.preventDefault;
|
||||||
originalEvent: event.originalEvent
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onCanvasKeyDown( event ) {
|
function onCanvasKeyDown( event ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user