mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 13:16:10 +03:00
MouseTracker preProcessEvent on key, focus, blur events
This commit is contained in:
parent
c38188927e
commit
2bbfa97063
@ -1211,7 +1211,7 @@
|
|||||||
* @property {Number} eventPhase
|
* @property {Number} eventPhase
|
||||||
* 0 == NONE, 1 == CAPTURING_PHASE, 2 == AT_TARGET, 3 == BUBBLING_PHASE.
|
* 0 == NONE, 1 == CAPTURING_PHASE, 2 == AT_TARGET, 3 == BUBBLING_PHASE.
|
||||||
* @property {String} eventType
|
* @property {String} eventType
|
||||||
* "contextmenu", "gotpointercapture", "lostpointercapture", "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerdown", "pointerup", "pointermove", "pointercancel", "wheel", "click", "dblclick".
|
* "keydown", "keyup", "keypress", "focus", "blur", "contextmenu", "gotpointercapture", "lostpointercapture", "pointerenter", "pointerleave", "pointerover", "pointerout", "pointerdown", "pointerup", "pointermove", "pointercancel", "wheel", "click", "dblclick".
|
||||||
* @property {String} pointerType
|
* @property {String} pointerType
|
||||||
* "mouse", "touch", "pen", etc.
|
* "mouse", "touch", "pen", etc.
|
||||||
* @property {Boolean} isEmulated
|
* @property {Boolean} isEmulated
|
||||||
@ -1812,9 +1812,16 @@
|
|||||||
*/
|
*/
|
||||||
function onKeyDown( tracker, event ) {
|
function onKeyDown( tracker, event ) {
|
||||||
//$.console.log( "keydown %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
//$.console.log( "keydown %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
||||||
var propagate;
|
var eventInfo = {
|
||||||
if ( tracker.keyDownHandler ) {
|
originalEvent: event,
|
||||||
propagate = tracker.keyDownHandler(
|
eventType: 'keydown',
|
||||||
|
pointerType: '',
|
||||||
|
isEmulated: false
|
||||||
|
};
|
||||||
|
preProcessEvent( tracker, eventInfo );
|
||||||
|
|
||||||
|
if ( tracker.keyDownHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
||||||
|
tracker.keyDownHandler(
|
||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
||||||
@ -1827,9 +1834,13 @@
|
|||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( !propagate ) {
|
}
|
||||||
$.cancelEvent( event );
|
|
||||||
}
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
||||||
|
$.cancelEvent( event );
|
||||||
|
}
|
||||||
|
if ( eventInfo.stopPropagation ) {
|
||||||
|
$.stopEvent( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1840,9 +1851,17 @@
|
|||||||
*/
|
*/
|
||||||
function onKeyUp( tracker, event ) {
|
function onKeyUp( tracker, event ) {
|
||||||
//$.console.log( "keyup %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
//$.console.log( "keyup %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
||||||
var propagate;
|
|
||||||
if ( tracker.keyUpHandler ) {
|
var eventInfo = {
|
||||||
propagate = tracker.keyUpHandler(
|
originalEvent: event,
|
||||||
|
eventType: 'keyup',
|
||||||
|
pointerType: '',
|
||||||
|
isEmulated: false
|
||||||
|
};
|
||||||
|
preProcessEvent( tracker, eventInfo );
|
||||||
|
|
||||||
|
if ( tracker.keyUpHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
||||||
|
tracker.keyUpHandler(
|
||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
||||||
@ -1855,9 +1874,13 @@
|
|||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( !propagate ) {
|
}
|
||||||
$.cancelEvent( event );
|
|
||||||
}
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
||||||
|
$.cancelEvent( event );
|
||||||
|
}
|
||||||
|
if ( eventInfo.stopPropagation ) {
|
||||||
|
$.stopEvent( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1868,9 +1891,17 @@
|
|||||||
*/
|
*/
|
||||||
function onKeyPress( tracker, event ) {
|
function onKeyPress( tracker, event ) {
|
||||||
//$.console.log( "keypress %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
//$.console.log( "keypress %s %s %s %s %s", event.keyCode, event.charCode, event.ctrlKey, event.shiftKey, event.altKey );
|
||||||
var propagate;
|
|
||||||
if ( tracker.keyHandler ) {
|
var eventInfo = {
|
||||||
propagate = tracker.keyHandler(
|
originalEvent: event,
|
||||||
|
eventType: 'keypress',
|
||||||
|
pointerType: '',
|
||||||
|
isEmulated: false
|
||||||
|
};
|
||||||
|
preProcessEvent( tracker, eventInfo );
|
||||||
|
|
||||||
|
if ( tracker.keyHandler && !eventInfo.preventGesture && !eventInfo.defaultPrevented ) {
|
||||||
|
tracker.keyHandler(
|
||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
keyCode: event.keyCode ? event.keyCode : event.charCode,
|
||||||
@ -1883,9 +1914,13 @@
|
|||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( !propagate ) {
|
}
|
||||||
$.cancelEvent( event );
|
|
||||||
}
|
if ( eventInfo.preventDefault && !eventInfo.defaultPrevented ) {
|
||||||
|
$.cancelEvent( event );
|
||||||
|
}
|
||||||
|
if ( eventInfo.stopPropagation ) {
|
||||||
|
$.stopEvent( event );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1896,9 +1931,20 @@
|
|||||||
*/
|
*/
|
||||||
function onFocus( tracker, event ) {
|
function onFocus( tracker, event ) {
|
||||||
//console.log( "focus %s", event );
|
//console.log( "focus %s", event );
|
||||||
var propagate;
|
|
||||||
if ( tracker.focusHandler ) {
|
// focus doesn't bubble and is not cancelable, but we call
|
||||||
propagate = tracker.focusHandler(
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
||||||
|
// if necessary
|
||||||
|
var eventInfo = {
|
||||||
|
originalEvent: event,
|
||||||
|
eventType: 'focus',
|
||||||
|
pointerType: '',
|
||||||
|
isEmulated: false
|
||||||
|
};
|
||||||
|
preProcessEvent( tracker, eventInfo );
|
||||||
|
|
||||||
|
if ( tracker.focusHandler && !eventInfo.preventGesture ) {
|
||||||
|
tracker.focusHandler(
|
||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
@ -1906,9 +1952,6 @@
|
|||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( propagate === false ) {
|
|
||||||
$.cancelEvent( event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1919,9 +1962,20 @@
|
|||||||
*/
|
*/
|
||||||
function onBlur( tracker, event ) {
|
function onBlur( tracker, event ) {
|
||||||
//console.log( "blur %s", event );
|
//console.log( "blur %s", event );
|
||||||
var propagate;
|
|
||||||
if ( tracker.blurHandler ) {
|
// blur doesn't bubble and is not cancelable, but we call
|
||||||
propagate = tracker.blurHandler(
|
// preProcessEvent() so it's dispatched to preProcessEventHandler
|
||||||
|
// if necessary
|
||||||
|
var eventInfo = {
|
||||||
|
originalEvent: event,
|
||||||
|
eventType: 'blur',
|
||||||
|
pointerType: '',
|
||||||
|
isEmulated: false
|
||||||
|
};
|
||||||
|
preProcessEvent( tracker, eventInfo );
|
||||||
|
|
||||||
|
if ( tracker.blurHandler && !eventInfo.preventGesture ) {
|
||||||
|
tracker.blurHandler(
|
||||||
{
|
{
|
||||||
eventSource: tracker,
|
eventSource: tracker,
|
||||||
originalEvent: event,
|
originalEvent: event,
|
||||||
@ -1929,9 +1983,6 @@
|
|||||||
userData: tracker.userData
|
userData: tracker.userData
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
if ( propagate === false ) {
|
|
||||||
$.cancelEvent( event );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2862,6 +2913,29 @@
|
|||||||
eventInfo.preventGesture = false;
|
eventInfo.preventGesture = false;
|
||||||
eventInfo.stopPropagation = false;
|
eventInfo.stopPropagation = false;
|
||||||
break;
|
break;
|
||||||
|
case 'keydown':
|
||||||
|
eventInfo.isStopable = true;
|
||||||
|
eventInfo.isCancelable = true;
|
||||||
|
eventInfo.preventDefault = !!tracker.keyDownHandler;
|
||||||
|
eventInfo.preventGesture = false;
|
||||||
|
eventInfo.stopPropagation = false;
|
||||||
|
break;
|
||||||
|
case 'keyup':
|
||||||
|
eventInfo.isStopable = true;
|
||||||
|
eventInfo.isCancelable = true;
|
||||||
|
eventInfo.preventDefault = !!tracker.keyUpHandler;
|
||||||
|
eventInfo.preventGesture = false;
|
||||||
|
eventInfo.stopPropagation = false;
|
||||||
|
break;
|
||||||
|
case 'keypress':
|
||||||
|
eventInfo.isStopable = true;
|
||||||
|
eventInfo.isCancelable = true;
|
||||||
|
eventInfo.preventDefault = !!tracker.keyHandler;
|
||||||
|
eventInfo.preventGesture = false;
|
||||||
|
eventInfo.stopPropagation = false;
|
||||||
|
break;
|
||||||
|
case 'focus':
|
||||||
|
case 'blur':
|
||||||
case 'pointerenter':
|
case 'pointerenter':
|
||||||
case 'pointerleave':
|
case 'pointerleave':
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user