<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: GWT Right-click Context Menu</title>
	<atom:link href="http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/feed/" rel="self" type="application/rss+xml" />
	<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/</link>
	<description>Discussions on Programming, Linux, Android, and whatever else!!!</description>
	<lastBuildDate>Wed, 15 Feb 2012 06:35:42 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Ben Howden</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-2/#comment-18747</link>
		<dc:creator>Ben Howden</dc:creator>
		<pubDate>Sun, 18 Dec 2011 23:57:26 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-18747</guid>
		<description>never mind I fexed a couple thangs and it werxd.
here&#039;s a new AudioWidget.java



Code:
&lt;pre&gt;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.PopupPanel;

/**
 *
 * @author fkasoft
 */
public class AudioWidget extends HTML {
    
    public static String filename = null;
    
    
    public AudioWidget(String sfilename, String iconUrl) {
        AudioWidget.filename=sfilename;
        setPixelSize(138, 130);
        setHTML(&quot;&quot;
            +&quot;&quot;+filename+&quot;&quot;);
    }
    
       @Override
        public void onBrowserEvent(Event event) {
                if( DOM.eventGetType(event) == Event.ONCLICK
                &amp;&amp; DOM.eventGetCtrlKey(event) ){

                }
                if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
                    GWT.log(&quot;Event.BUTTON_RIGHT&quot;, null);
                    onRightClickBroker(this, event);
                }
                sinkEvents(Event.ONMOUSEUP &#124; Event.ONDBLCLICK &#124; Event.ONCONTEXTMENU);
                super.onBrowserEvent(event);
            }
        
 

            private void onRightClickBroker(HTML aThis, Event event) {
                
                final PopupPanel popupPanel = new PopupPanel();
                popupPanel.setPixelSize(85, 100);
                
                Command showPlayerCommand = new Command() {
                  public void execute() {
                   
                    popupPanel.hide();
                    MainEntryPoint.aPanel.remove(popupPanel);
                    
                  }
                };

            
                
                  MainEntryPoint.rightClickFired=true;
                  // Window.alert(&quot;audio icon right clicked&quot;);
                  MenuBar popupMenuBar = new MenuBar(true);
                  MenuItem playerItem = new MenuItem(&quot;Play&quot;, true, showPlayerCommand);
                
                  
                    popupMenuBar.addItem(playerItem);
                    popupMenuBar.setVisible(true);
                    popupPanel.add(popupMenuBar);
    
                     DOM.setStyleAttribute(popupPanel.getElement(), &quot;background-color&quot;, &quot;gray&quot;);
                      DOM.setStyleAttribute(popupPanel.getElement(), &quot;border-color&quot;, &quot;gray gray gray gray&quot;);
                      DOM.setStyleAttribute(popupPanel.getElement(), &quot;border-width&quot;, &quot;1px 3px 3px 1px&quot;);
                      DOM.setStyleAttribute(popupPanel.getElement(), &quot;border-style&quot;, &quot;solid solid solid solid&quot;);
                      DOM.setStyleAttribute(playerItem.getElement(), &quot;font-weight&quot;, &quot;normal&quot;);
                      DOM.setStyleAttribute(playerItem.getElement(), &quot;font-size&quot;, &quot;80%&quot;);
                    
                    popupPanel.setVisible(true);
                    MainEntryPoint.aPanel.add(popupPanel, event.getClientX(), event.getClientY());
                  
               
                
            }
}


&lt;/pre&gt;
</description>
		<content:encoded><![CDATA[<p>never mind I fexed a couple thangs and it werxd.<br />
here&#8217;s a new AudioWidget.java</p>
<p>Code:</p>
<pre>
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Command;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.MenuBar;
import com.google.gwt.user.client.ui.MenuItem;
import com.google.gwt.user.client.ui.PopupPanel;

/**
 *
 * @author fkasoft
 */
public class AudioWidget extends HTML {

    public static String filename = null;

    public AudioWidget(String sfilename, String iconUrl) {
        AudioWidget.filename=sfilename;
        setPixelSize(138, 130);
        setHTML(""
            +""+filename+"");
    }

       @Override
        public void onBrowserEvent(Event event) {
                if( DOM.eventGetType(event) == Event.ONCLICK
                &amp;&amp; DOM.eventGetCtrlKey(event) ){

                }
                if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
                    GWT.log("Event.BUTTON_RIGHT", null);
                    onRightClickBroker(this, event);
                }
                sinkEvents(Event.ONMOUSEUP | Event.ONDBLCLICK | Event.ONCONTEXTMENU);
                super.onBrowserEvent(event);
            }

            private void onRightClickBroker(HTML aThis, Event event) {

                final PopupPanel popupPanel = new PopupPanel();
                popupPanel.setPixelSize(85, 100);

                Command showPlayerCommand = new Command() {
                  public void execute() {

                    popupPanel.hide();
                    MainEntryPoint.aPanel.remove(popupPanel);

                  }
                };

                  MainEntryPoint.rightClickFired=true;
                  // Window.alert("audio icon right clicked");
                  MenuBar popupMenuBar = new MenuBar(true);
                  MenuItem playerItem = new MenuItem("Play", true, showPlayerCommand);

                    popupMenuBar.addItem(playerItem);
                    popupMenuBar.setVisible(true);
                    popupPanel.add(popupMenuBar);

                     DOM.setStyleAttribute(popupPanel.getElement(), "background-color", "gray");
                      DOM.setStyleAttribute(popupPanel.getElement(), "border-color", "gray gray gray gray");
                      DOM.setStyleAttribute(popupPanel.getElement(), "border-width", "1px 3px 3px 1px");
                      DOM.setStyleAttribute(popupPanel.getElement(), "border-style", "solid solid solid solid");
                      DOM.setStyleAttribute(playerItem.getElement(), "font-weight", "normal");
                      DOM.setStyleAttribute(playerItem.getElement(), "font-size", "80%");

                    popupPanel.setVisible(true);
                    MainEntryPoint.aPanel.add(popupPanel, event.getClientX(), event.getClientY());

            }
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Howden</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-18746</link>
		<dc:creator>Ben Howden</dc:creator>
		<pubDate>Sun, 18 Dec 2011 23:05:48 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-18746</guid>
		<description>now when I try to add a custom context menu over my AudioWidget 
it doesn&#039;t clear the widget when a menu item is pressed and
it pops up a default browser context menu (in Google Chrome) 
over the AudioWidget.</description>
		<content:encoded><![CDATA[<p>now when I try to add a custom context menu over my AudioWidget<br />
it doesn&#8217;t clear the widget when a menu item is pressed and<br />
it pops up a default browser context menu (in Google Chrome)<br />
over the AudioWidget.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Howden</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-18742</link>
		<dc:creator>Ben Howden</dc:creator>
		<pubDate>Sun, 18 Dec 2011 21:27:02 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-18742</guid>
		<description>just noticed the arbitrary rootpanel oh well. I didn&#039;t check it or clean it up it I just ran it.</description>
		<content:encoded><![CDATA[<p>just noticed the arbitrary rootpanel oh well. I didn&#8217;t check it or clean it up it I just ran it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Howden</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-18719</link>
		<dc:creator>Ben Howden</dc:creator>
		<pubDate>Sun, 18 Dec 2011 07:38:27 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-18719</guid>
		<description>hey this dusty thread needs some activity. so here&#039;s what I did. I ran into trouble applying different 
right click events to different widgets. When I had a widget on top of an AbsolutePanel that responded to a right click I got execution of both onRightClickBroker methods so I set up a simple static boolean class member in MainEntryClass and referenced it within second panel when it&#039;s event fired. When you have one widget on top of a Panel it seems to hear the Panel event 2nd. don&#039;t know why but it was a pain in the ass...

here&#039;s the main

public class MainEntryPoint implements EntryPoint {

    /** 
     * Creates a new instance of MainEntryPoint
     */
    
    public static RootPanel rootPanel;
    
    static { rootPanel = null; }
    
    
    public static boolean rightClickFired = false;
    
    public MainEntryPoint() {
    }
 
    public static AbsolutePanel aPanel = null;
    
    public void onModuleLoad() {
        
        
       // panelMenu.
        
        
        RootPanel.get().setPixelSize(800, 1200);
        aPanel = new AbsolutePanel(){
        
        
            public void onBrowserEvent(Event event) {
                if( DOM.eventGetType(event) == Event.ONCLICK
                &amp;&amp; DOM.eventGetCtrlKey(event) ){

                }
                if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
                    GWT.log(&quot;Event.BUTTON_RIGHT&quot;, null);
                    onRightClickBroker(this, event);
                }

                super.onBrowserEvent(event);
            }

            private void onRightClickBroker(AbsolutePanel aThis, Event event) {
                
                if(!rightClickFired)
                    Window.alert(&quot;Panel Clicked&quot;);
                else
                    rightClickFired=false;
               
                
            }
            
            
        
        };
        
        
        aPanel.sinkEvents(Event.ONCLICK &#124; Event.ONMOUSEDOWN);
        aPanel.setPixelSize(800, 1200);
       
        // register a drag controller with RootPanel
         PickupDragController dragController = 
                new PickupDragController(aPanel, true);
        
        dragController.setBehaviorConstrainedToBoundaryPanel(true);
        
        
       Widget folderWidget = new FolderWidget
               (&quot;images/folder.png&quot;);
       Widget imgWidget = new ImageWidget
               (&quot;images/asianguy.jpg&quot;,&quot;asianguy.jpg&quot;);
       Widget audioWidget = new AudioWidget
               (&quot;2000 Live On Earth (CD 2)-04 Namah Shivayah.mp3&quot;,&quot;images/audio.png&quot;);
        
        dragController.makeDraggable(imgWidget);
        dragController.makeDraggable(audioWidget);
        dragController.makeDraggable(folderWidget);
        SimpleDropController dropController = new SimpleDropController(folderWidget);
        
        dragController.registerDropController(dropController);
        
        aPanel.add(folderWidget, 25, 50);
        aPanel.add(imgWidget, 250, 50);
        aPanel.add(audioWidget, 25, 250);
       RootPanel.get().add(aPanel, 0 , 0);
        
    }
}
//
// AND HERE&#039;s and example of AudioWidget.java

public class AudioWidget extends HTML {
    public AudioWidget(String filename, String iconUrl) {
        setPixelSize(138, 130);
        setHTML(&quot;&quot;
            +&quot;&quot;+filename+&quot;&quot;);
    }
        public void onBrowserEvent(Event event) {
                if( DOM.eventGetType(event) == Event.ONCLICK
                &amp;&amp; DOM.eventGetCtrlKey(event) ){

                }
                if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {
                    GWT.log(&quot;Event.BUTTON_RIGHT&quot;, null);
                    onRightClickBroker(this, event);
                }

                super.onBrowserEvent(event);
            }
        
    @Override
    public void sinkEvents(int eventBitsToAdd) {
        super.sinkEvents(Event.ONCLICK &#124; Event.ONMOUSEDOWN);
    }

            private void onRightClickBroker(HTML aThis, Event event) {
                
                MainEntryPoint.rightClickFired=true;
                Window.alert(&quot;audio icon right clicked&quot;);
               
                
            }
}</description>
		<content:encoded><![CDATA[<p>hey this dusty thread needs some activity. so here&#8217;s what I did. I ran into trouble applying different<br />
right click events to different widgets. When I had a widget on top of an AbsolutePanel that responded to a right click I got execution of both onRightClickBroker methods so I set up a simple static boolean class member in MainEntryClass and referenced it within second panel when it&#8217;s event fired. When you have one widget on top of a Panel it seems to hear the Panel event 2nd. don&#8217;t know why but it was a pain in the ass&#8230;</p>
<p>here&#8217;s the main</p>
<p>public class MainEntryPoint implements EntryPoint {</p>
<p>    /**<br />
     * Creates a new instance of MainEntryPoint<br />
     */</p>
<p>    public static RootPanel rootPanel;</p>
<p>    static { rootPanel = null; }</p>
<p>    public static boolean rightClickFired = false;</p>
<p>    public MainEntryPoint() {<br />
    }</p>
<p>    public static AbsolutePanel aPanel = null;</p>
<p>    public void onModuleLoad() {</p>
<p>       // panelMenu.</p>
<p>        RootPanel.get().setPixelSize(800, 1200);<br />
        aPanel = new AbsolutePanel(){</p>
<p>            public void onBrowserEvent(Event event) {<br />
                if( DOM.eventGetType(event) == Event.ONCLICK<br />
                &amp;&amp; DOM.eventGetCtrlKey(event) ){</p>
<p>                }<br />
                if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {<br />
                    GWT.log(&#8220;Event.BUTTON_RIGHT&#8221;, null);<br />
                    onRightClickBroker(this, event);<br />
                }</p>
<p>                super.onBrowserEvent(event);<br />
            }</p>
<p>            private void onRightClickBroker(AbsolutePanel aThis, Event event) {</p>
<p>                if(!rightClickFired)<br />
                    Window.alert(&#8220;Panel Clicked&#8221;);<br />
                else<br />
                    rightClickFired=false;</p>
<p>            }</p>
<p>        };</p>
<p>        aPanel.sinkEvents(Event.ONCLICK | Event.ONMOUSEDOWN);<br />
        aPanel.setPixelSize(800, 1200);</p>
<p>        // register a drag controller with RootPanel<br />
         PickupDragController dragController =<br />
                new PickupDragController(aPanel, true);</p>
<p>        dragController.setBehaviorConstrainedToBoundaryPanel(true);</p>
<p>       Widget folderWidget = new FolderWidget<br />
               (&#8220;images/folder.png&#8221;);<br />
       Widget imgWidget = new ImageWidget<br />
               (&#8220;images/asianguy.jpg&#8221;,&#8221;asianguy.jpg&#8221;);<br />
       Widget audioWidget = new AudioWidget<br />
               (&#8220;2000 Live On Earth (CD 2)-04 Namah Shivayah.mp3&#8243;,&#8221;images/audio.png&#8221;);</p>
<p>        dragController.makeDraggable(imgWidget);<br />
        dragController.makeDraggable(audioWidget);<br />
        dragController.makeDraggable(folderWidget);<br />
        SimpleDropController dropController = new SimpleDropController(folderWidget);</p>
<p>        dragController.registerDropController(dropController);</p>
<p>        aPanel.add(folderWidget, 25, 50);<br />
        aPanel.add(imgWidget, 250, 50);<br />
        aPanel.add(audioWidget, 25, 250);<br />
       RootPanel.get().add(aPanel, 0 , 0);</p>
<p>    }<br />
}<br />
//<br />
// AND HERE&#8217;s and example of AudioWidget.java</p>
<p>public class AudioWidget extends HTML {<br />
    public AudioWidget(String filename, String iconUrl) {<br />
        setPixelSize(138, 130);<br />
        setHTML(&#8220;&#8221;<br />
            +&#8221;"+filename+&#8221;");<br />
    }<br />
        public void onBrowserEvent(Event event) {<br />
                if( DOM.eventGetType(event) == Event.ONCLICK<br />
                &amp;&amp; DOM.eventGetCtrlKey(event) ){</p>
<p>                }<br />
                if (DOM.eventGetButton(event) == Event.BUTTON_RIGHT) {<br />
                    GWT.log(&#8220;Event.BUTTON_RIGHT&#8221;, null);<br />
                    onRightClickBroker(this, event);<br />
                }</p>
<p>                super.onBrowserEvent(event);<br />
            }</p>
<p>    @Override<br />
    public void sinkEvents(int eventBitsToAdd) {<br />
        super.sinkEvents(Event.ONCLICK | Event.ONMOUSEDOWN);<br />
    }</p>
<p>            private void onRightClickBroker(HTML aThis, Event event) {</p>
<p>                MainEntryPoint.rightClickFired=true;<br />
                Window.alert(&#8220;audio icon right clicked&#8221;);</p>
<p>            }<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-17324</link>
		<dc:creator>Kim</dc:creator>
		<pubDate>Thu, 17 Nov 2011 12:54:18 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-17324</guid>
		<description>I&#039;ve experimented with a lot of things now, especially using the ContextMenuHandler, but only one thing is working in both FF6 and IE8. Here is my widget on which I want a context menu:

&lt;code&gt;
public class ContextMenuHorizontalPanel extends HorizontalPanel {

		public void onBrowserEvent(Event event) {
			GWT.log(&quot;onBrowserEvent&quot;, null);

			switch (DOM.eventGetType(event)) {
			case Event.ONCONTEXTMENU:
				GWT.log(&quot;Event.ONCONTEXTMENU&quot;, null);
				event.stopPropagation();//This will stop the event from being propagated
				event.preventDefault();
				listener.onRightClick(myObject, event);
				break;

			default:
				break; // Do nothing
			}//end switch
		}
	}
&lt;/code&gt;

What&#039;s important is that I stopped sinking ONMOUSEUP events (or more precisely, I&#039;ve stopped acting on them). The fact that I was doing my context menu in the ONMOUSEUP seems to have prevented the stopPropagation and preventDefault from being effective on the ONCONTEXTMENU? I&#039;m not sure exactly what&#039;s going on, but I&#039;m happy to find something that finally works without having to disable the default context menu on the whole application.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve experimented with a lot of things now, especially using the ContextMenuHandler, but only one thing is working in both FF6 and IE8. Here is my widget on which I want a context menu:</p>
<p><code><br />
public class ContextMenuHorizontalPanel extends HorizontalPanel {</p>
<p>		public void onBrowserEvent(Event event) {<br />
			GWT.log("onBrowserEvent", null);</p>
<p>			switch (DOM.eventGetType(event)) {<br />
			case Event.ONCONTEXTMENU:<br />
				GWT.log("Event.ONCONTEXTMENU", null);<br />
				event.stopPropagation();//This will stop the event from being propagated<br />
				event.preventDefault();<br />
				listener.onRightClick(myObject, event);<br />
				break;</p>
<p>			default:<br />
				break; // Do nothing<br />
			}//end switch<br />
		}<br />
	}<br />
</code></p>
<p>What&#8217;s important is that I stopped sinking ONMOUSEUP events (or more precisely, I&#8217;ve stopped acting on them). The fact that I was doing my context menu in the ONMOUSEUP seems to have prevented the stopPropagation and preventDefault from being effective on the ONCONTEXTMENU? I&#8217;m not sure exactly what&#8217;s going on, but I&#8217;m happy to find something that finally works without having to disable the default context menu on the whole application.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kim</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-17188</link>
		<dc:creator>Kim</dc:creator>
		<pubDate>Tue, 15 Nov 2011 16:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-17188</guid>
		<description>From GWT 2.0, cancelBubble() is deprecated. I don&#039;t know what we are supposed to use in its place. The code works fine in Firefox 6, but I tried in IE 8 and I still get the browser&#039;s context menu. I tried making a native function that simply sets window.event.cancelBubble = true, but it doesn&#039;t work either - IE complains that window.event is null.

Any ideas why this doesn&#039;t work on GWT2? BTW, I&#039;m using GWT 2.2.</description>
		<content:encoded><![CDATA[<p>From GWT 2.0, cancelBubble() is deprecated. I don&#8217;t know what we are supposed to use in its place. The code works fine in Firefox 6, but I tried in IE 8 and I still get the browser&#8217;s context menu. I tried making a native function that simply sets window.event.cancelBubble = true, but it doesn&#8217;t work either &#8211; IE complains that window.event is null.</p>
<p>Any ideas why this doesn&#8217;t work on GWT2? BTW, I&#8217;m using GWT 2.2.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Santlal</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-15197</link>
		<dc:creator>Santlal</dc:creator>
		<pubDate>Sat, 01 Oct 2011 11:33:01 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-15197</guid>
		<description>Hello
I am using above example with gwt 2.3 I does not prevent context menu . Could anyone please help me. Thanks in advance.</description>
		<content:encoded><![CDATA[<p>Hello<br />
I am using above example with gwt 2.3 I does not prevent context menu . Could anyone please help me. Thanks in advance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sebastian</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-3669</link>
		<dc:creator>Sebastian</dc:creator>
		<pubDate>Mon, 27 Sep 2010 13:53:14 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-3669</guid>
		<description>Thank, man! This really helped.</description>
		<content:encoded><![CDATA[<p>Thank, man! This really helped.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daghan</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-3510</link>
		<dc:creator>Daghan</dc:creator>
		<pubDate>Sun, 19 Sep 2010 06:37:33 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-3510</guid>
		<description>I am using GWT 2.1.0 M3 and I think the code below is bit more concise and shorter (it is MVP style)

public class BrowserPresenter implements ContextMenuHandler {
	private BrowserView view;  // a composite widget
	
	public BrowserPresenter(Widget _view) {
		view = (BrowserView) _view;
		view.browserTree.addDomHandler(this, ContextMenuEvent.getType());
	}
	
	@Override
	public void onContextMenu(ContextMenuEvent event) {
		event.stopPropagation();     //This will stop the event from being propagated to parent elements.
		event.preventDefault();        // because cancelBubble(Boolean) is deprecated
		Window.alert(&quot;replace this line with your popup function &quot;);
	}</description>
		<content:encoded><![CDATA[<p>I am using GWT 2.1.0 M3 and I think the code below is bit more concise and shorter (it is MVP style)</p>
<p>public class BrowserPresenter implements ContextMenuHandler {<br />
	private BrowserView view;  // a composite widget</p>
<p>	public BrowserPresenter(Widget _view) {<br />
		view = (BrowserView) _view;<br />
		view.browserTree.addDomHandler(this, ContextMenuEvent.getType());<br />
	}</p>
<p>	@Override<br />
	public void onContextMenu(ContextMenuEvent event) {<br />
		event.stopPropagation();     //This will stop the event from being propagated to parent elements.<br />
		event.preventDefault();        // because cancelBubble(Boolean) is deprecated<br />
		Window.alert(&#8220;replace this line with your popup function &#8220;);<br />
	}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: holter</title>
		<link>http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/comment-page-1/#comment-2980</link>
		<dc:creator>holter</dc:creator>
		<pubDate>Mon, 30 Aug 2010 13:42:21 +0000</pubDate>
		<guid isPermaLink="false">http://whatwouldnickdo.com/wordpress/?p=370#comment-2980</guid>
		<description>Hi Nick, thanks for the code. Save a lot of time. One small comment.

In IE8   did not work.
I had to use an explicte script (stolen from another site...).


function mycontextmenu()
{
	return false;
}
document.oncontextmenu = mycontextmenu;


Then suppression of the context menu in IE worked as well as in FireFox.</description>
		<content:encoded><![CDATA[<p>Hi Nick, thanks for the code. Save a lot of time. One small comment.</p>
<p>In IE8   did not work.<br />
I had to use an explicte script (stolen from another site&#8230;).</p>
<p>function mycontextmenu()<br />
{<br />
	return false;<br />
}<br />
document.oncontextmenu = mycontextmenu;</p>
<p>Then suppression of the context menu in IE worked as well as in FireFox.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

