0

Disable Menu

asked 2009-10-29 04:04:42 +0800

SergeTk gravatar image SergeTk
193 3

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.........

delete flag offensive retag edit

9 Replies

Sort by ยป oldest newest

answered 2009-10-29 08:32:04 +0800

christhornley gravatar image christhornley
78 1

I had this problem also. My workaround was to just replace it with a (disabled) menu item when I wanted it disabled.

link publish delete flag offensive edit

answered 2009-10-31 23:14:42 +0800

SergeTk gravatar image SergeTk
193 3

Thanks Im going to do the same ..............

link publish delete flag offensive edit

answered 2009-11-01 19:19:08 +0800

tmillsclare gravatar image tmillsclare
799 2 5 30

That is a good workaround, I have also posted a feature request related to this issue here.

link publish delete flag offensive edit

answered 2016-02-18 08:40:10 +0800

WilliamB gravatar image WilliamB
1609 1 6

any news on this? I'm in the same need ...

Seems your feature request was closed but cant find its duplicate artifact 2883553

link publish delete flag offensive edit

answered 2016-02-18 11:03:08 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

http://tracker.zkoss.org/browse/ZK-141

link publish delete flag offensive edit

answered 2016-02-18 13:35:28 +0800

WilliamB gravatar image WilliamB
1609 1 6

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.

link publish delete flag offensive edit

answered 2016-02-19 10:41:35 +0800

chillworld gravatar image chillworld flag of Belgium
5367 4 9
https://github.com/chillw...

Thx for posting your solution.

link publish delete flag offensive edit

answered 2016-02-19 13:21:37 +0800

WilliamB gravatar image WilliamB
1609 1 6

Too bad you cannot vote on this though ...

link publish delete flag offensive edit

answered 2016-02-20 14:43:39 +0800

terrytornado gravatar image terrytornado flag of Germany
9393 3 7 16
http://www.oxitec.de/

Thanx too for the solution

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-10-29 04:04:42 +0800

Seen: 548 times

Last updated: Feb 20 '16

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More