You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by jr801 <tr...@gmail.com> on 2012/08/04 19:43:19 UTC

how to add persistent context-menu on treebranch node

Hi,

After looking at this thread:
http://apache-pivot-users.399431.n3.nabble.com/context-menu-on-treeNode-tt4021940.html#a4021945

I implemented the following code:

MyTreeView.setMenuHandler(new MenuHandler.Adapter() { 

public boolean configureContextMenu( Component component, Menu menu, int x,
int y ) {
    if (!my_menu_added) { 
     // add menu-section/menu-items ... 
     my_menu_added=true; 
   } 
   return false; 
} 
} 

So the question is, can I make a context-menu persistent on a
TreeBranch-object? Because the second time I right-click on the tree-node,
my_menu_added will be false and so the menu won't pop-up.
 

thanks




--
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/how-to-add-persistent-context-menu-on-treebranch-node-tp4022002.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: how to add persistent context-menu on treebranch node

Posted by Josh R <tr...@gmail.com>.
On Sun, Aug 5, 2012 at 5:23 PM, Roger and Beth Whitcomb
<Ro...@rbwhitcomb.com> wrote:
>
> Thanks for using Pivot!
>
> You have the right interface for adding the context menus.  But, each time
> it is called there will be a different Menu object.  You can persist your
> planned menu objects any way you want.  In our application we defined them

I see. I save node-specific info using TreeBranch.setUserData. So the
Menu.Items can go there.

> HTH,
> ~Roger Whitcomb

thanks

Re: how to add persistent context-menu on treebranch node

Posted by Roger and Beth Whitcomb <Ro...@rbwhitcomb.com>.
Thanks for using Pivot!

You have the right interface for adding the context menus.  But, each 
time it is called there will be a different Menu object.  You can 
persist your planned menu objects any way you want.  In our application 
we defined them in a bxml file and just saved pointers to each 
Menu.Section inside one Java class.  Then (depending on the context) we 
add the appropriate sections to the passed in Menu object.

The logic you have won't work because there is always a new Menu object 
each time the method is called.  But, you can persist your Menu.Item (or 
Menu.Section) objects so they just have to be added each time (but not 
recreated).

HTH,
~Roger Whitcomb

On 8/4/12 10:43 AM, jr801 wrote:
> Hi,
>
> After looking at this thread:
> http://apache-pivot-users.399431.n3.nabble.com/context-menu-on-treeNode-tt4021940.html#a4021945
>
> I implemented the following code:
>
> MyTreeView.setMenuHandler(new MenuHandler.Adapter() {
>
> public boolean configureContextMenu( Component component, Menu menu, int x,
> int y ) {
>      if (!my_menu_added) {
>       // add menu-section/menu-items ...
>       my_menu_added=true;
>     }
>     return false;
> }
> }
>
> So the question is, can I make a context-menu persistent on a
> TreeBranch-object? Because the second time I right-click on the tree-node,
> my_menu_added will be false and so the menu won't pop-up.
>   
>
> thanks
>
>
>
>
> --
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/how-to-add-persistent-context-menu-on-treebranch-node-tp4022002.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>
>