0

How to load context menu with code. [closed]

asked 2013-01-18 02:37:51 +0800

jasonhoo gravatar image jasonhoo
104 4

I want create a popupmenu and load it as context menu, but it doesn't work.
The context menu must be appended by a compnent which is its parent ? Help me, thanks !

          Menupopup menupopup = new Menupopup();
          Menuitem itemSelectAll = new Menuitem("SelectAll");
          itemSelectAll.addEventListener("onClick", new EventListener()
          {
            public void onEvent(org.zkoss.zk.ui.event.Event event)
                throws Exception
            {
              ....
            }
          });
          menupopup.appendChild(itemSelectAll);
          menupopup.appendChild(itemInverse);
          ((Listheader) header).setContext(menupopup);

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by sjoshi
close date 2013-02-08 07:20:38

4 Answers

Sort by ยป oldest newest most voted
0

answered 2013-01-21 16:09:02 +0800

jasonhoo gravatar image jasonhoo
104 4

updated 2013-01-21 16:10:15 +0800

I try use menupopup.setPage(this.getPage()), and it run OK. Thanks very much !

          Menupopup menupopup = new Menupopup();
          Menuitem itemSelectAll = new Menuitem("SelectAll");
          itemSelectAll.addEventListener("onClick", new EventListener()
          {
            public void onEvent(org.zkoss.zk.ui.event.Event event)
                throws Exception
            {
              ....
            }
          });
          menupopup.appendChild(itemSelectAll);
          menupopup.appendChild(itemInverse);
          // it's here ....  <------------------------------
          menupopup.setPage(header.getPage());
          ((Listheader) header).setContext(menupopup);

link publish delete flag offensive edit
1

answered 2013-01-20 10:43:17 +0800

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

In easiest way, have a look what is the window component which is outer of your stuff and set it as parent.

menupopup.setParent(outerWindow);

link publish delete flag offensive edit
0

answered 2013-01-21 15:38:25 +0800

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

Ups, my fault. The parent of a MenuPopup is menu.

link publish delete flag offensive edit
0

answered 2013-01-21 13:33:31 +0800

jasonhoo gravatar image jasonhoo
104 4

updated 2013-01-21 13:35:03 +0800

If the root tag is 'window', it's OK! But it's parent is tag 'center', and root tag is 'zk' which use getParent() return null.

<zk>
    <borderlayout>
         <center>
              <listbox ....>
                 ....
              </listbox>
         </center>
    </borderlayout>
</zk>

link publish delete flag offensive edit

Question tools

Follow

RSS

Stats

Asked: 2013-01-18 02:37:51 +0800

Seen: 88 times

Last updated: Jan 21 '13

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