You are correct - there is no way to determine if a menu belongs to a menu bar, 
menu button, or context menu - menus don't maintain a reference to any kind of 
"owner" component, aside from the parent Menu.Item (which is null if a menu is 
the root menu).

Using separate actions (which possibly share a common base class) seems like a 
good idea.

G

On Sep 14, 2010, at 11:21 AM, Roger L. Whitcomb wrote:

> I’m working with the latest changes to 1.5.2/2.0 to pass in the Component to 
> the Action.perform() method(s), and I’m still having trouble with 
> differentiating the source of the action, particularly for context menus vs. 
> regular menus.  I (rather naively) thought that I could test to see if the 
> Menu.Item was ultimately parented by a MenuBar or not to differentiate the 
> regular window menu from a right-click menu.  Not so – both end up parented 
> by a MenuPopup attached to the Display.  Then I thought I could use 
> “isContextMenu()” from MenuPopup, which does work, but not for submenus…. L  
> Is this a bug, or a misunderstanding on my part?  Is there any other way to 
> tell whether the menu item is coming from a right-click menu or the menu bar? 
>  Thanks.
>  
> The use case here is that I have some right-click menu items that do the same 
> action as regular menu items, but with different context.  Right now, I 
> mapped them both to the same action.  But, maybe I need to make separate 
> actions and that will solve it.  The case where the action is invoked from a 
> toolbar vs. a menu is solved with the Component being passed in (also the 
> shortcut key case).
>  
>  
>  
> Roger Whitcomb
> Architect, Engineering
> Ingres Corporation
> [email protected]
>  
> PHONE +1 650.587.5596
> FAX +1 650.587.5550
>  
> www.ingres.com
>  
> This transmission is confidential and intended solely for the use of the 
> recipient named above. It may contain confidential, proprietary, or legally 
> privileged information. If you are not the intended recipient, you are hereby 
> notified that any unauthorized review, use, disclosure or distribution is 
> strictly prohibited. If you have received this transmission in error, please 
> contact the sender by reply e-mail and delete the original transmission and 
> all copies from your system.
>  

Reply via email to