⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 eventhandler.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
    // because it is occluded by something that proxies events to it    if (!targetAtPoint && mouseDownTarget._proxiers != null) {        for (var i = 0; i < mouseDownTarget._proxiers.length; i++) {            targetAtPoint = mouseDownTarget._proxiers[i].visibleAtPoint(lastEvent.x, lastEvent.y, true);            if (targetAtPoint) break;        }    }    lastEvent._stillWithin = targetAtPoint;    return targetAtPoint;},//>	@classMethod	isc.EventHandler.handleMouseMove()// Starts dragging if the dragTarget is set and the mouse has moved more than [5] pixels//	// Sets the dropTarget if we're dragging and are over a droppable target//// Generates mouseOver/mouseOut or dragOver/dragOut events on Canvas boundaries.////		@group	mouseEvents////		@param	DOMevent	(DOM event) DOM event object (as passed by isc.EventHandler)////		@return				(boolean)	false == cancel native event processing//										anything else == continue native event processing// @visibility internal//<// called directly by DOMhandleMouseMove : function (DOMevent) {	// Some browsers (like Mac IE) have problems dealing with events fired before the page    // finishes loading.  Just skip mouse event processing if the page hasn't loaded yet.	if (!isc.Page.isLoaded()) return false;            var EH = isc.EH;        if (EH._handlingMouseDown || EH._handlingMouseUp) return;	var event = EH.getMouseEventProperties(DOMevent);        if ((isc.Browser.isMoz || isc.Browser.isIE)            ) {        //Log.logWarn("postponing mouseMove (last time: " + EH.lastMouseMoveTime +         //            " exceeds threshold of " + EH.delayThreshold);        // set a timer to fire mouseMove later        if (EH.delayedMouseMoveTimer == null) {            EH.delayedMouseMoveTimer =                  isc.Timer.setTimeout({target:EH, methodName:"_delayedMouseMove",                                       args:[isc.timeStamp()]}, 0);        }        EH._lastMouseMoveTime = 0;                return true;    }    var start = isc.timeStamp();    var result = EH._handleMouseMove(DOMevent, event);    EH._lastMouseMoveTime = isc.timeStamp() - start;    //if (EH.lastMouseMoveTime > 100) Log.logWarn("Last mouseMove time: " + EH._lastMouseMoveTime);    return result;},_delayedMouseMove : function (ts) {    //var now = isc.timestamp();    //if ((now - ts) > 30) {    //    this.logWarn("long timer firing delay: " + (now-ts) + "ms");    //}    this.delayedMouseMoveTimer = null;    //var start = isc.timeStamp();    this._handleMouseMove(null, this.lastEvent);    //var end = isc.timeStamp();    //if ((end - start) > 5) {    //    this.logWarn("long mouse move: " + (now-ts) + "ms");    //}},_handleMouseMove : function (DOMevent, event) {    this._handlingMouseMove = true;    var returnVal = this.__handleMouseMove(DOMevent, event);    this._handlingMouseMove = null;    return returnVal;},__handleMouseMove : function (DOMevent, event) {    var EH = this;            var missedMouseUp;    if (isc.Browser.isIE) {        var mouseIsDown = EH._mouseIsDown, buttonNum = event.buttonNum;        if (mouseIsDown) {                        if (buttonNum == 0) {                EH._mouseIsDown = false;                missedMouseUp = true;            }                } else if (buttonNum == 1 && event.eventType == EH.MOUSE_MOVE) {            event.eventType = EH.MOUSE_DOWN;            EH.handleMouseDown(null, event);            event.eventType = EH.MOUSE_MOVE;        }    }     	var target = event.target, 		isNative = EH.eventHandledNatively(EH.MOUSE_MOVE, event.nativeTarget) 	;    	if (EH._mouseIsDownInScrollbar) {                EH.handleMouseUp(DOMevent, true);        } else if (EH._outOfWindow && missedMouseUp) {        EH.logInfo("sythesizing mouseUp due to mouseUp outside window, buttonNum: " +                    event.buttonNum);        EH.handleMouseUp(DOMevent, true);    }    delete EH._outOfWindow;        // NOTE: we allow right mouse button dragging, and at the EventHandler level we treat it    // just like normal dragging, however, a specific drag handler can implement special    // semantics for right dragging.        var mouseDown = EH.mouseIsDown();    if (isc.Browser.isMoz && mouseDown && event.target && event.target._useMozScrollbarsNone         && event.target != EH.mouseDownTarget())     {        event.nativeTarget = null;        target = event.target = EH.mouseDownTarget();    }    // start dragging if:    // - the mouse is down    // - the mouse went down on a Canvas that allows dragging (EH.dragTarget, set up in     //   prepareForDragging)    // - we're not already dragging    // - the mouse has moved a certain distance, in either direction, from the mouseDown point	if (mouseDown && EH.dragTarget && ! EH.dragging 		&& (Math.abs( event.x - EH.mouseDownEvent.x) > EH.dragTarget.dragStartDistance 		 || Math.abs( event.y - EH.mouseDownEvent.y) > EH.dragTarget.dragStartDistance))     {        EH.handleDragStart(event);	}		// if we're dragging, jump over to handleDragMove which does special processing	if (EH.dragging) return EH.handleDragMove();	// if the right button is down	if (EH.rightButtonDown()) {		// don't send mouseMove.  We could send a 'rightMouseMove' event, but we've decided not        // to do that now.                        if (!isc.Browser.isMac || !EH.ctrlKeyDown()) return true;	}      	if (mouseDown) {        target = EH.stillWithinMouseDownTarget() ? EH.mouseDownTarget() : null;	} else {		target = event.target;	}	// if the target is not the last object that got the move event,	// send the mouseOut and mouseOver routines to the appropriate objects	if (target != EH.lastMoveTarget) {        //>DEBUG        if (this.logIsDebugEnabled()) {            this.logDebug((EH.lastMoveTarget ?                            "mousing out of " + EH.lastMoveTarget + "  " : "") +                           (target ? "mousing over " + target : ""));        }        //<DEBUG		// send the mouseOut event to the last mover object        var lastMoveTarget = EH.lastMoveTarget,            hoverTarget,            lastHoverTarget = EH.lastHoverTarget;            		if (lastMoveTarget) {            EH.handleEvent(lastMoveTarget, EH.MOUSE_OUT);        }                        // send the mouseOver event to the target        if (target) {            EH.handleEvent(target, EH.MOUSE_OVER);            // use 'getHoverTarget()' to determine which widget should recieve a hover event.            hoverTarget = target.getHoverTarget(event);        }                // Send hover events to the hover target/last hover target.        // The Canvas level implementation handles actually setting up timers to fire         // user-visible hover handlers.            if (hoverTarget != lastHoverTarget) {            if (lastHoverTarget) lastHoverTarget.stopHover();            if (hoverTarget) hoverTarget.startHover();                        EH.lastHoverTarget = hoverTarget;        }				// remember that we're the last move object		EH.lastMoveTarget = target;	}	// call the global event handler	if (isc.Page.handleEvent(target, EH.MOUSE_MOVE) == false) return false;	// see if we shouldn't pass this event on to DOM object, and return true if we should	if (isNative) return EH._handledNativelyReturnVal;	// if the target isn't defined or isn't enabled, return false	if (!EH.targetIsEnabled(target)) return false;	// bubble the event	EH.bubbleEvent(target, EH.MOUSE_MOVE);    // update the cursor	if (target) target._updateCursor();    	        return true;    },// handle a native mouseOut eventhandleNativeMouseOut : function (DOMevent) {    // we generally synthesize the mouseOut event during mouseMove.  However, for the special    // case of mousing out of the browser window via exiting a Canvas which is which is flush    // with the window border, we'll never get a mouseMove outside of our Canvas, so we have to    // detect this case specially.        if (isc.Browser == null) return;	        var EH = isc.EH;        if (EH._handlingMouseDown || EH._handlingMouseUp) return;    var event = (DOMevent ? DOMevent : EH.getWindow().event),		target = (isc.Browser.isDOM ? event.target : event.srcElement),        leavingWindow = false;    if (isc.Browser.isIE) {                leavingWindow = (event.toElement == null);            } else {                leavingWindow = (event.relatedTarget == null);            }    //EH.logWarn("leaving window:" + leavingWindow + ", lastMoveTarget: " + EH.lastMoveTarget);    // used for detecting mouseUps that happen outside the window, where possible    if (leavingWindow) EH._outOfWindow = true;       if (leavingWindow && EH.lastMoveTarget != null) {        // Update properties on the lastEvent object before bubbling handlers.                EH._updateMouseOutEventProperties(event);        EH.handleEvent(EH.lastMoveTarget, EH.MOUSE_OUT);        EH.lastMoveTarget = null;        if (EH.lastHoverTarget) {            EH.lastHoverTarget.stopHover();            delete EH.lastHoverTarget;        }    }},// update lastEvent with properties from a native 'mouseOut' event._updateMouseOutEventProperties : function (nativeEvent) {	        var EH = isc.EH;    var lastEvent = EH.lastEvent;    // Store the target we're moving into as the event target (rather than the target we're    // moving out of!)    if (isc.Browser.isIE) {        lastEvent.nativeTarget = nativeEvent.toElement;        } else {        lastEvent.nativeTarget = nativeEvent.relatedTarget;    }    if (lastEvent.nativeTarget == null) lastEvent.target = null    else lastEvent.target = this.getEventTargetCanvas(nativeEvent, lastEvent.nativeTarget);    },// Send the mouseDown target a periodic, synthetic "still down" event while the mouse stays// down//// Allows for things like repeated scrolling while the mouse button is held down in// scrollbar buttons.//// NOTE: mouseStillDown is also fired once immediately on mouseDown_handleMouseStillDown : function (timeStamp) {	// Some browsers (like Mac IE) have problems dealing with events fired before the page    // finishes loading.  Just skip mouse event processing if the page hasn't loaded yet.	if (!isc.Page.isLoaded()) return false;	var EH = this;		// clear the old timeout if necessary    EH._stillDownTimer = isc.Timer.clear(EH._stillDownTimer);		// if the mouse is already up, or the mouseDownTarget can no longer be found, bail    	if (!EH.mouseIsDown() || !EH.mouseDownTarget()) return false;		// send the event up the chain of the target	if (EH.bubbleEvent(EH.mouseDownTarget(), EH.MOUSE_STILL_DOWN) == false) return false;    	// start the timer to call this again after a delay.          var target = EH.mouseDownTarget(),        delay = this._handlingMouseDown ? target.mouseStillDownInitialDelay :                                          target.mouseStillDownDelay;  	EH._stillDownTimer = this.delayCall("_handleMouseStillDown", [], delay);    // alternate code that allows checking the actual delay before the timer fired    //if (!this._handlingMouseDown) {    //    this.logWarn("mouseStillDown fired after: " + (isc.timeStamp() - timeStamp) + "ms");    //}  	//EH._stillDownTimer =     //    isc.Timer.setTimeout("isc.EH._handleMouseStillDown(" + isc.timeStamp() + ")", delay);	return true;},//>	@classMethod	isc.EventHandler.handleMouseUp()//			Special handler for mouse up events.////			fires  showContextMenu, click and doubleClick events as necessary////		@group	mouseEvents//		@param	DOMevent	(DOM event) DOM event object (as passed by isc.EventHandler)////		@return				(boolean)	false == cancel native event processing//										anything else == continue native event processing//  @visibility internal//<// called directly from DOM, and by other methodshandleMouseUp : function (DOMevent, fakeEvent) {        	        var EH = i

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -