在PopupMenuBarItem的鼠标悬停期间设置背景颜色

时间:2011-06-15 18:34:21

标签: dojo

寻找一些帮助,找出如何改变背景和 鼠标悬停期间dijit.PopupMenuBarItem对象上的字体颜色。该 当按住指针时,鼠标悬停的默认颜色当前为浅蓝色 菜单栏中的“文件”。我看过cssStateNodes,但我不这么认为 是我正在寻找的。目前正在使用dojo 1.5.0 ......

dojo.require("dijit.MenuBar");
dojo.require("dijit.MenuBarItem");
dojo.require("dijit.PopupMenuBarItem");
dojo.require("dijit.Menu");
dojo.require("dijit.MenuItem");
dojo.require("dijit.PopupMenuItem");

var pMenuBar;
dojo.addOnLoad(function() {
  pMenuBar = new dijit.MenuBar({
    style: "background-color: #495569"
    });

  var pSubMenu = new dijit.Menu({});
  pSubMenu.addChild(new dijit.MenuItem({
    label: "File item #1"
    }));

  pMenuBar.addChild(new dijit.PopupMenuBarItem({
    label: "File",
    style: "color: white",
    popup: pSubMenu
    }));

  pMenuBar.placeAt("dojoMenu");
  pMenuBar.startup();
});

感谢您的帮助......

1 个答案:

答案 0 :(得分:0)

弄清楚如何完成这项工作:

var pSubMenu2 = new dijit.Menu({
  onFocus: function() {
    var obj = dijit.byId('editID');
    if (obj) {
      obj.attr('style','color: black');
    } 
  },
  onBlur: function() {
    var obj = dijit.byId('editID');
    if (obj) {
      obj.attr('style','color: white');
    } 
  },
  onMouseDown: function() {
    var obj = dijit.byId('editID');
    if (obj) {
      obj.attr('style','color: white');
    } 
  }
});

pSubMenu2.addChild(new dijit.MenuItem({
  onMouseOver: function() {
    var obj = dijit.byId('editID');
    if (obj) {
      obj.attr('style','color: black');
    }
  },
  label: "Edit item #1"
  }));

pSubMenu2.addChild(new dijit.MenuItem({
  onMouseOver: function() {
    var obj = dijit.byId('editID');
    if (obj) {
      obj.attr('style','color: black');
    }
  },
  label: "Edit item #2"
  }));

pMenuBar.addChild(new dijit.PopupMenuBarItem({
  id: "editID",
  label: "Edit",
  style: "color: white",
  onMouseOver: function() {
    this.attr('style','color: black');
  },
  onMouseLeave: function() {
    this.attr('style','color: white');
  },
  popup: pSubMenu2
  }));