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

📄 menubar.js

📁 javascript 很酷的类库
💻 JS
📖 第 1 页 / 共 2 页
字号:
        else if (!this.menus.contains(menu)) continue;        newMenusArray.remove(menu);        // form a list of generated MenuBarButtons to remove        var index = this.menus.indexOf(menu);        if (this._buttonsInitialized) membersToRemove.add(this.members[index]);    }        if (!this._buttonsInitialized) {        this.menus = newMenusArray;        return;        }        for (var i = 0; i < this.menus.length; i++) {        if (this.menus[i] == newMenusArray[i]) continue;        this._remapButton(this.members[i], newMenusArray.indexOf(this.menus[i]));    }        this.menus = newMenusArray;    this.removeButtons(membersToRemove);},//>	@method	menuBar.showMenu()// Shows (opens) a menu.// @param   menu    (Menu | integer) menu to show (may be specified as a menu object, or index of//                                   the menu from +link{menuBar.menus, this.menus}).  // @visibility external//<showMenu : function (menuNum) {    var menu;    if (isc.isA.Number(menuNum)) menu = this.menus[menuNum];    else {        menu = menuNum;        menuNum = this.menus.indexOf(menu);    }    // could be a canvas or an object here, I guess	if (!menu) {		//>DEBUG		this.logWarn("showMenu() called with invalid menu number: " + menuNum + ".  No effect.");		//<DEBUG		return;	}        var button;    for (var i = 0; i < this.members.length; i++) {        if (this.members[i].menuNum == menuNum) {            button = this.members[i];        }    }      if (!isc.isA.Canvas(menu)) {		if (menu.ID == null) menu.ID = this.getID()+"_menu"+menuNum;		menu.autoDraw = false;		menu = this.menus[menuNum] =             isc.ClassFactory.newInstance(this.menuConstructor, menu, this.menuDefaults);	}		// hide whichever menu is currently showing (leaving the clickMask up)    if (this.activeMenu != null) {        this.menus[this.activeMenu].hideMenuTree();    }            menu.eventParent = this;    	// move the menu into place and show it	(automatically will be moved above clickmask)    menu.moveTo(button.getPageLeft(), button.getPageBottom());	menu.show();        // Don't set the "down" state on the button til after the menu has shown     // Otherwise when the clickMask shows, the button will be returned to state "up"    // Also, while the menu is showing, avoid respoding to mouseOvers    button._previousShowOver = button.showRollOver;    button.showRollOver = false;	button.setState(isc.StatefulCanvas.STATE_DOWN);    // update this.activeMenu.    // Note - when a menu is shown, the menuBar-button observes the hide method on the menu, to    // reset it's visible state, and to clear 'activeMenu' from the menuBar.	this.activeMenu = menuNum;	if (!button.isObserving(menu,"hide")) {		button.observe(menu,"hide","observer.menuHidden(observed)");	}	    // bring the menuBar to the front so that they can switch to other menus    var EH = isc.EH;    if (EH.targetIsMasked(this)) this.bringToFront();        // When the clickMask was shown by the first button clicked, one of our menu buttons had focus    // and was therefore remembered as the maskedFocusCanvas.    // Our buttons are no longer masked (bringToFront() above) so focussing on them won't update    // the maskedFocusCanvas meaning it is essentially out of date at this point.    // Clear this property so focus doesn't go back to the first button pushed when the clickMask    // is hidden by menu.hideAllMasks()    var topMask = EH.clickMaskRegistry.last(),        maskedFocusCanvas = EH.getMaskedFocusCanvas(topMask);    if (this.members.contains(maskedFocusCanvas)) EH.setMaskedFocusCanvas(null, topMask);        // Update menu.focusOnHide to ensure that when the menu hides focus goes to the appropriate    // button        menu.body.focusOnHide = button;},_focusInNextButton : function (forward) {    if (!this.activeMenu == null) return this.Super("_focusInNextButton", arguments);    if (forward == null) forward = true;        // In this case, we're showing a menu, and the user pressed the left or right arrow    // key.    // Instead of shifting focus to the next button, show the next menu    var activeMenu = this.activeMenu,        step = forward ? 1 : -1,        currentMenu = activeMenu + step,        members = this.getMembers();            while (activeMenu != currentMenu) {        if (currentMenu < 0) currentMenu = members.length -1;        else if (currentMenu >= this.members.length) currentMenu = 0;        var button = members[currentMenu];        if (!button.isDisabled()) {            button.showMenu();            break;        }        currentMenu += step;    }},// override getFocusButtonIndex to return the button with an activeMenu, if one is defined, even// if it doesn't have focusgetFocusButtonIndex : function () {    if (this.activeMenu != null) return this.activeMenu;    return this.Super("getFocusButtonIndex",arguments);},// Avoid bubbling mouse events.mouseDown:function () { return false; },mouseUp:function () { return false; },click:function () { return false; }});//>	@class	MenuBarButton// Subclass of Button only used to show buttons in a MenuBar widget.// <p>// Allows mousing between MenuButtons in the same MenuBar to pop open Menus without a click.// Also ensures that only one Menu from the MenuBar is showing at any given time.////  @treeLocation Client Reference/Foundation//<isc.ClassFactory.defineClass("MenuBarButton","MenuButton");isc.MenuBarButton.addProperties({    showMenuButtonImage:false,	showDown:false,	autoDraw:false,    align:"center"});isc.MenuBarButton.addMethods({        // show menu on mouseOver if another menu in the menuBar is showing its menu    // XXX unfortunately we don't get mouseMove while the mouse is down if the mouse went down    // on another widget.  See EventHandler for why.    mouseOver : function () {        this.Super("mouseOver", arguments);        // if another menu is currently being shown, show our menu instead.        var activeMenuNum = this.parentElement.activeMenu;    	if (activeMenuNum != null && activeMenuNum != this.menuNum) {            this.showMenu();        }    },        // override mouseDown to show menu (rather than click)    mouseDown : function () {    	// if this menu button is the one showing it's menu, hide it    	if (this.parentElement.activeMenu == this.menuNum) {    		isc.Menu.hideAllMenus();    	// otherwise show it    	} else {            this.showMenu();        }    },    // override mouseUp and click to do nothing    mouseUp : function () {},    click : function () {},    mouseOut : function () {    	if (this.parentElement.activeMenu != this.menuNum) {    		this.Super("mouseOut", arguments);    	}    },        // Override handleKeyPress - we're going to be firing showMenu() rather than click()    handleKeyPress : function (event, eventInfo) {            if (event.keyName == "Space" || event.keyName == "Enter") return this.showMenu();                if (this.keyPress) {            this.convertToMethod("keyPress");            return this.keyPress(event, eventInfo);        }    },        // override showMenu to delegate up to the menuBar    showMenu : function () {        this.parentElement.showMenu(this.menuNum);    },        menuHidden : function (menu) {        if (isc._traceMarkers) arguments.__this = this;        // When the menu got shown we put the button into a 'down' state        // Clear this now.                if (this.state == isc.StatefulCanvas.STATE_DOWN) {            if (this.hasFocus && this.showFocused) this.setState(isc.StatefulCanvas.STATE_OVER);            else this.setState(isc.StatefulCanvas.STATE_UP);        }                 this.showRollOver = this._previousShowOver;        delete this._previousShowOver;    	this.menuIsDown = false;          	if (this.parentElement.activeMenu == this.menuNum) {    		this.parentElement.activeMenu = null;    	}    }});

⌨️ 快捷键说明

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