Mohan -
We spent some time looking into this issue for you and here is what we
discovered:
The fundamental problem is the "contextmenu" event is not bubbling up
from the <applet> element. As the YAHOO.widget.ContextMenu class is
designed to listen for the "contextmenu" event, it makes sense why it is
not working for you.
But SHOULD events bubble up from an <applet> element? Well, we looked
into it. The HTML 4.01 specification doesn't mention events for the
<applet> element.
http://www.w3.org/TR/html401/struct/objects.html#edef-APPLET
However, the spec does mention that the <applet> element is deprecated
in favor of <object> element. And both the HTML 4.01 specification and
MSDN indicate that the <object> tag DOES support the bubbling of DOM events:
http://www.w3.org/TR/html401/struct/objects.html#edef-OBJECT
http://msdn.microsoft.com/workshop/author/dhtml/reference/objects/object.asp
From MSDN: "Events are sent directly to the OBJECT element. If the
event is returned by the embedded object, it bubbles accordingly. If the
event is not returned, it does not bubble."
With that information we put together a test page
(http://www.yuiblog.com/sandbox/yui/v221/examples/menu/applet_object_test.php)
that listens for some DOM events (specifically "mousedown", "mouseup",
"click" and "contextmenu") on an empty <object> and <applet> element and
tested it in each of our supported browsers
(http://developer.yahoo.com/yui/articles/gbs/) to get a feel for the
default behavior. Here are the results:
Browser <object> <applet>
------------------------------------
IE 6 X X
IE 7 X -
FF 2.0 (Win) X -
FF 1.5 (Win) X -
FF 2.0 (OS X) X X
FF 1.5 (OS X) X X
Safari 2.0 X -
Opera 9 (Win) X -
Opera 9 (OS X) X -
X = DOM events bubble
- = DOM events do not bubble
So, the results were *pretty much* on par with the spec: DOM events
don't bubble from an <applet> element in MOST of our support browsers,
but DO bubble from the <object> element.
This gave us hope. So, we created a new test page
(http://www.yuiblog.com/sandbox/yui/v221/examples/menu/object_test.php)
that used the <object> element to embed an actual Java Applet. Here are
the results of that test:
Browser Object
----------------------
IE 6 -
IE 7 -
FF 2.0 (Win) -
FF 1.5 (Win) -
FF 2.0 (OS X) X
FF 1.5 (OS X) X
Safari 2.0 X
Opera 9 (Win) -
Opera 9 (OS X) -
X = DOM events bubble
- = DOM events do not bubble
The results of this test *seem* to indicate that by default in MOST of
our support browsers, NO EVENTS bubble up from a Java Applet once it is
initialized. This leaves you with three possible options:
1) Explore some means of implementing an Applet so that it doesn't stop
the propagation of DOM events to the browser
2) Consider writing the context menu in Java and making it part of the
Applet itself
3) Use LiveConnect to make events you capture in Java available to your
JavaScript
I hope that this information is helpful to you. Good luck with your
project.
- Todd
mohan kumar wrote:
>
>
> */mohan kumar <tmk_mohankumar@...>/* wrote:
>
> Hi,
> Context menu is not coming for applet.
>
> Code written by me:
>
> I created Applet tag Like this:-
>
> <ul id = 'graphList'>
> <li><applet Code = "example.class"></applet></li>
> </ul>
> and in java script :-
>
> var list = document.getElementById('graphList');
>
> now i created context menu:-
>
> aMenuItems = [{ text: "Large View"},{ text: "Rename"},{ text:
> "Delete"}];
>
> I attached context menu to applet:-
>
> var graphContextMenu = new
> YAHOO.widget.ContextMenu("contextmenu",{trigger:
> list.childNodes,itemdata:aMenuItems,lazyload: true,iframe:true});
>
> when i right click on applet the menu is not coming at all in
> IE,but the menu is coming for firefox.
>
> why the menu is not coming for IE when i click on applet in IE.
>
> thanks,
> mohan
>
>
> ------------------------------------------------------------------------
> The fish are biting.
> Get more visitors
>
<http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsore\
dsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50>
> on your site using Yahoo! Search Marketing.
>
<http://us.rd.yahoo.com/evt=49679/*http://searchmarketing.yahoo.com/arp/sponsore\
dsearch_v2.php?o=US2140&cmp=Yahoo&ctv=Q107Tagline&s=Y&s2=EM&b=50>
>
>
>
> ------------------------------------------------------------------------
> Get your own web address.
>
<http://us.rd.yahoo.com/evt=49678/*http://smallbusiness.yahoo.com/domains/?p=BES\
TDEAL>
> Have a HUGE year through Yahoo! Small Business.
>
<http://us.rd.yahoo.com/evt=49678/*http://smallbusiness.yahoo.com/domains/?p=BES\
TDEAL>
>