-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I need to disable a Menu as it stands right now there no setDisabled on the menu .............. I wonder why??
Any one has idea how i can get it to work without forking 2 much staff in the process.........
I had this problem also. My workaround was to just replace it with a (disabled) menu item when I wanted it disabled.
That is a good workaround, I have also posted a feature request related to this issue here.
Thanks Chill. Here is my work around :
MyMenu.java :
import org.zkoss.zk.ui.ext.AfterCompose;
import org.zkoss.zul.Menu;
public class MyMenu extends Menu implements AfterCompose {
private boolean disabled;
private Menu disabledMenu;
@Override
public void afterCompose() {
disabledMenu = new Menu(getLabel());
disabledMenu.setSclass(getSclass() + " " + "disabled");
getParent().insertBefore(disabledMenu, this);
disabledMenu.setVisible(disabled);
setVisible(!disabled);
}
public void setDisabled(final boolean pDisabled) {
disabled = pDisabled;
if (disabledMenu != null) {
disabledMenu.setVisible(disabled);
setVisible(!disabled);
}
}
}
lang-addon.xml:
<component>
<component-name>menu</component-name>
<extends>menu</extends>
<component-class>mypackage.MyMenu</component-class>
</component>
My SCSS:
.z-menu.disabled {
opacity: .6;
filter: alpha(opacity=60);
border: 1px solid transparent;
background: 0;
filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
cursor: default;
-webkit-box-shadow: none;
box-shadow: none;
.z-menu-content:hover {
color: #555;
cursor: default;
}
}
And now I can set diabled attribut on menu. Didn't find an easy way to prevent the menupopup from opening, so went with creating a disabled version of my menu and only displaying one at a time.
Thx for posting your solution.
Thanx too for the solution
Asked: 2009-10-29 04:04:42 +0800
Seen: 548 times
Last updated: Feb 20 '16