0

Can a Context menu recognize what component was right-clicked?

asked 2010-07-21 12:34:18 +0800

darius gravatar image darius
279 3

I have a tabbox with many tabs. I want the user to be able to right-click on any of the tabs and it will pop-up a context menu. The options in the menu are the same for all the tabs. Can I use a single Menupopup or do I need separate Menupops for each Tab?
If I can use a single Menupopup, how do I detect which tab caused it to popup?

delete flag offensive retag edit

2 Replies

Sort by ยป oldest newest

answered 2010-07-21 14:31:57 +0800

twiegand gravatar image twiegand
1807 3

updated 2010-07-21 15:44:02 +0800

Darius,

Here is some code that illustrates what you ask:

<zk>
	<window>
		<tabbox>
			<tabs>
				<tab id="tab1" label="Tab #1" context="editPopup"/>
				<tab id="tab2" label="Tab #2" context="editPopup"/>
				<tab id="tab3" label="Tab #3" context="editPopup"/>
			</tabs>
			<tabpanels>
				<tabpanel >
					<label value="Content for Tab #1"/>
				</tabpanel>
				<tabpanel>
					<label value="Content for Tab #2"/>
				</tabpanel>
				<tabpanel>
					<label value="Content for Tab #3"/>
				</tabpanel>
			</tabpanels>
		</tabbox>
		<menupopup id="editPopup">
			<attribute name="onOpen">
				if(event.isOpen()){
					Component callingComp = event.getReference();
					msg.setLabel("Called from "+callingComp.getLabel());
				}
			</attribute>
			<menuitem id="msg" />
			<menuseparator />
			<menuitem label="File" />
			<menuitem label="Edit" />
		</menupopup>
		
	</window>
</zk>

As you can see, there is only one Menupop and when you right click on any of the tabs, the context menu will indicate which tab it was called from...

Hope that is of value to you.

Kind regards,

Todd

link publish delete flag offensive edit

answered 2010-07-22 05:38:39 +0800

darius gravatar image darius
279 3

Thanks Todd, I didn't realize there was that specific Event type (OpenEvent), which had the getReference() method that I could use.

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: 2010-07-21 12:34:18 +0800

Seen: 445 times

Last updated: Jul 22 '10

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