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

📄 eventhandler.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 5 页
字号:
	// call the global keyPress event (Set up via Page.setEvent("keyPress",...) )	if (isc.Page.handleEvent(lastEvent.keyTarget, eventType) == false) return false;        // If eventHandledNatively returns true don't fire widget level handlers, or allow     // registered keys to fire their actions.	// NOTE: in IE, this will return the key number so we pass that value on	var it = (EH.eventHandledNatively(eventType, lastEvent.nativeKeyTarget));    	if (it !== false) {        //>DEBUG        EH.logDebug("keyPress handled natively");        //<DEBUG        return EH._handledNativelyReturnVal;            } else {        //>DEBUG        EH.logDebug("keyPress not handled natively");        //<DEBUG    }        var target = lastEvent.keyTarget;    if (target == null) target = this.getEventTargetCanvas(nativeEvent,                                                           lastEvent.nativeKeyTarget);    // Pass to the appropriate widget, and stop if this returns false.    if (EH.targetIsEnabled(target)) {        var handlerReturn = EH.bubbleEvent(target, lastEvent.eventType, eventInfo)         if (handlerReturn == false) return false;    }    	if (handlerReturn != EH.STOP_BUBBLING         && isc.Page.handleKeyPress() == false) return false;            // If we got a tab or shift-tab keypress, and we're showing a hard mask, explicitly stick    // focus into the next widget in the page's tab order that isn't masked.        if (this.clickMaskUp() && lastEvent.keyName == this._$Tab) {        var topHardMask,            registry = this.clickMaskRegistry;        for (var i = registry.length-1; i >=0; i--) {            if (this.isHardMask(registry[i])) {                topHardMask = registry[i];                break;            }        }        if (topHardMask != null) {            var focusCanvas = EH._focusCanvas;                        if (focusCanvas != null) {                //>DEBUG                this.logInfo("Telling focus canvas:" + focusCanvas + " to shift focus",                             "syntheticTabIndex")                //<DEBUG                focusCanvas._focusInNextTabElement(!this.shiftKeyDown(), topHardMask);            } else {                if (this.shiftKeyDown()) {                    //>DEBUG                    this.logInfo("Putting focus into last widget in response to Tab keydown",                                "syntheticTabIndex")                    //<DEBUG                                    this._focusInLastWidget(topHardMask);                } else {                    //>DEBUG                    this.logInfo("Putting focus into first widget in response to Tab keydown",                                "syntheticTabIndex")                    //<DEBUG                    this._focusInFirstWidget(topHardMask);                }            }            // Always return false natively in this case - we don't want the focus to shift again            return false;        }    }            if (isc.Browser.isIE && lastEvent.keyName == isc.EH._$f10 && isc.EH.shiftKeyDown()) {        var returnVal = this.handleContextMenu(nativeEvent);        if (returnVal) {            this._contextMenuShown = true;        }        return returnVal;    }        // In Moz hitting "Escape" during server turnaround (either XMLHttpRequest, or iframe)    // kills the communication.    // Avoid this by suppressing native Escape behavior during active comm.        // Note: Opera has the same bug if using hidden frames (though not XMLHttpRequest)    // but returning false from the Escape keypress doesn't resolve the issue in that browser.    if (isc.Browser.isMoz &&        isc.RPCManager && isc.RPCManager._activeTransactions.length > 0        && lastEvent.keyName == isc.EH._$Escape)     {        return false;    }    	// return true to allow normal event processing unless anything explicitly returned false	return true;},// Helper methods to put focus at the beginning or end of our managed tab-index._focusInFirstWidget : function (mask) {    var widget = this._firstTabWidget;    if (widget) {        if ((!mask || !this.targetIsMasked(widget, mask)) && !widget.isDisabled() &&               widget._canFocus())         {            // Call 'focusAtEnd()' rather than focus()            // if the widget manages the tab index of sub elements (EG DynamicForm), we want            // to notify it to put focus in the first sub element.            widget.focusAtEnd(true);        } else {            widget._focusInNextTabElement(true, mask);        }    }},_focusInLastWidget : function (mask) {    var widget = this._lastTabWidget;    if (widget) {        if ((!mask || !this.targetIsMasked(widget, mask)) && !widget.isDisabled() &&              widget._canFocus())         {            widget.focusAtEnd();        } else {            widget._focusInNextTabElement(false, mask);        }                }}, //>	@classMethod	isc.EventHandler.handleMouseDown()//			Special handler for mouseDown events.//          Starts a timer to fire mouseStillDown if the target implements it.//			sets the following variables for use in subsequent events//				...////		@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//<handleMouseDown : function (DOMevent, syntheticEvent) {	        var EH = isc.EH;    EH._handlingMouseDown = true;    var returnValue = EH.doHandleMouseDown(DOMevent, syntheticEvent);    EH._handlingMouseDown = false;        return returnValue;},_$IMG:"IMG",_$alphaImgFilter:"progid:DXImageTransform.Microsoft.AlphaImageLoader",doHandleMouseDown : function (DOMevent, syntheticEvent) {	// 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;	// note that the mouse is down.  We do this BEFORE getting event properties to work around a bug	// in Nav where the event.which (property to get the mouse button) is reported as 1 on a	// mouseMove, even when the mouse is actually not pressed.	EH._mouseIsDown = true;	// get the properties of the event    	var	event = syntheticEvent || EH.getMouseEventProperties(DOMevent);    // if we switched event target, get rid of the focus        var focusCanvas = EH._focusCanvas,        forceBlur = focusCanvas != null &&                    (focusCanvas != event.target) && !focusCanvas._useNativeTabIndex &&                     !focusCanvas._useFocusProxy &&                     !(isc.isA.DynamicForm!=null && isc.isA.DynamicForm(focusCanvas) && focusCanvas.getFocusItem()                       && focusCanvas.getFocusItem().hasFocus);    if (forceBlur) {        // In IE if we blur() here, the thing we clicked on never gets native focus (not clear         // why), so do this on a timeout, if appropriate        if (isc.Browser.isIE) {            var ID = EH._focusCanvas.getID();                        if (EH._delayedBlurArray == null)                 EH._delayedBlurArray = ["if (", ID, " && ", ID, ".hasFocus)", ID, ".blur()"]            else                 EH._delayedBlurArray[1] = EH._delayedBlurArray[3] = EH._delayedBlurArray[5] = ID;            isc.Timer.setTimeout(                EH._delayedBlurArray.join(isc.emptyString),                0            );                    } else {            EH._focusCanvas.blur();        }    }            	// remember a copy of the event particulars as mouseDownEvent	EH.mouseDownEvent = isc.addProperties({}, event);		// get the target Canvas	var target = event.target;    // handle mouseDown on the virtual click mask, if it's showing.      // If this is an hard clickMask, the click action will be cancelled by the    // mask - since we actually do this on mouseDown, we need to set a flag to also    // cancel mouseUp when it happens.            var targetIsMasked = (EH.clickMaskClick(target) == false);	if (targetIsMasked) {        EH.__cancelNextMouseUp = true;        return false;    } else {        // explicitly set the flag to NOT cancel the next mouseUp - this is required to note that         // we've fired the clickMaskClick()        // See comments in handleMouseUp() for more details        EH.__cancelNextMouseUp = false;    }    // NOTE: although we do send a rightMouseDown, we don't send a rightMouseMove or rightMouseUp at    // the moment.  rightMouseDown is needed to implement a cell or record selection model that    // matches Windows Explorer and Excel respectively - rightMouseMove and rightMouseUp are more    // exotic.    var eventType = EH.rightButtonDown() ? EH.RIGHT_MOUSE_DOWN : EH.MOUSE_DOWN;	// call the global mouseDown handler	if (isc.Page.handleEvent(target, eventType) == false) {        return false;    }	// see if we shouldn't pass this event on to DOM object, and return true if we should	if (EH.eventHandledNatively(eventType, event.nativeTarget))         return EH._handledNativelyReturnVal;	// if the target is not enabled, we shouldn't continue    if (!EH.targetIsEnabled(target)) return false;        if (target && !target.hasFocus) {        // call 'focus' to focus on the widget.                    if ( ((isc.Browser.isMoz && target.canSelectText) || isc.Browser.isSafari )             && target._useFocusProxy )         {            EH.focusInCanvas(target);                            } else if (!target._useNativeTabIndex) {            target.focus();                } else if (isc.Browser.isMoz) {            target.focus();                        } else if (isc.Browser.isIE) {            var nativeElement = event.nativeTarget;            if (nativeElement && nativeElement.tagName == this._$IMG) {                var style = nativeElement.style,                    filter = style ? style.filter : null;                if (filter.contains(this._$alphaImgFilter)) {                    target.focus();                }            }        }    }         // NOTE that we allow right drag, and treat it just like left drag, although you can do    // something special on right drag by checking EH.rightButtonDown()    if (target) EH.prepareForDragging(target);    // bubble the mouseDown event to anyone who wants it    var handlerReturn = EH.bubbleEvent(target, eventType, null, targetIsMasked);	if (handlerReturn == false) {        // a an explicit "false" returned from mouseDown will cancel dragging        delete EH.dragTarget;        delete EH.dragTargetLink;    }	// if the right button is down, the return value can affect the context menu.    // In DOM browsers, we receive a native showContextMenu event (see    // this.handleContextMenu()), and our response to that affects whether the context    // menu will be shown.	if (EH.rightButtonDown()) {        // Bail unless we're in a browser where we never get a separate right-mouse event        if (!this.useSyntheticRightButtonEvents()) return true;                  if (target &&             (EH.getBubbledProperty(target, "contextMenu") ||              EH.getBubbledProperty(target, "showContextMenu") != isc.Canvas.getInstanceProperty("showContextMenu")))         {        			// return false to suppress native context menu, since we'll show our own on mouseUp            //this.logWarn("rightMouseDown: false");            event.returnValue = false;			return false;		}        // return true to allow the context menu in Nav4.  Note that when we return true here, we        // never get mouseUp in Nav4.        //Log.logWarn("rightMouseDown: true");        return true;	}    // if the mouseDown handler didn't return false, set up a timer to send mouseStillDown events	if (handlerReturn != false) {			// if the target or a parent has a mouseStillDown message fire the mouseStillDown event,		// this will keep firing on a timer until the mouse goes up		if (EH.hasEventHandler(target, EH.MOUSE_STILL_DOWN)) {			// call _handleMouseStillDown, which will start the timer automatically			EH._handleMouseStillDown();		}	}            var aboutToDrag = EH.dragTarget != null;    // Return false to cancel native drag mode if we're about to do an ISC drag.    // Return false in Moz if text selection is diallowed        // (type-casting target._allowNativeTextSelection() to a boolean - if this     // returns undef we want to  return an explicit false so drag selection is disallowed)    var returnVal =  (!aboutToDrag &&                         (!(isc.Browser.isMoz || isc.Browser.isSafari) ||                          !!target._allowNativeTextSelection(event)));    return returnVal;},//>	@classMethod	isc.EventHandler.stillWithinMouseDownTarget()//	Is the current event still within the last Canvas where the mouse went down?//  Note: You need to call this method to get correct cross-platform determination of whether//        the current event is still within the mouseDown target.//		@group	mouseEvents// @visibility internal//<stillWithinMouseDownTarget : function () {    var mouseDownTarget = this.mouseDownTarget();    if (!mouseDownTarget) return false; // mouse didn't go down in a Canvas    var lastEvent = this.lastEvent;    // see if we're within the same Canvas that the mouse went down in    var stillWithin = (mouseDownTarget == lastEvent.target);    if (!stillWithin) return false;    if (lastEvent._stillWithin != null) return lastEvent._stillWithin;        if (!(isc.Browser.isMoz && mouseDownTarget._useMozScrollbarsNone))     {        return stillWithin;    }    var x = lastEvent.x,        y = lastEvent.y,        targetAtPoint = mouseDownTarget.visibleAtPoint(x, y, true);    // check for the case where the mouseDownTarget should be regarded as visible at the point

⌨️ 快捷键说明

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