0

I my Gadget application i have an issue with showing standard gadget context menu. The problem caused because of silverlight control, when i click right button Silverligh control handle contextmenu event.

So first my solution was to put on top of the silverlight control transprent web control (table). Well that way i got good working gadget context menu and not working silverlight control. So the next step was to make transperent web control invisible and handle oncontextmenu. Like this.

HTML

<body oncontextmenu="ContextMenu();" onload="init();" >

JavaScript

ContextMenu()
{
var vis = document.getElementById('overlapControl').style.visibility;
if (vis == "hidden") {
    document.getElementById('overlapControl').style.visibility = "visible";
    window.event.returnValue = false;
}

It's working with some glitches. You need to make two right button clicks, and some event to hide transpanent control. The second one is not a big problem, i can use onmouseover event for example to hide control. But a first one is a real pain in the neck. Seems there is no way to show context menu with one click.

Any ideas how to make it work. or maybe other better solution.

Denis Kucherov
  • 369
  • 3
  • 15

1 Answers1

1

Have you tried windowless mode? Here is a little more complicated example, but should give you some idea.

macwier
  • 1,063
  • 1
  • 6
  • 19
  • Yes is there. – Denis Kucherov May 25 '12 at 08:19
  • thank you for that reference. here is more recent one. http://blogs.microsoft.co.il/blogs/alex_golesh/archive/2008/05/28/how-to-handle-rightclick-mouse-event-in-silverlight-take-2.aspx in a first glance i get the idea how to provide click event up to managed code, but is it possible then to fire gadget context menu event from silverlight control? – Denis Kucherov May 25 '12 at 08:41
  • I don't think that this example put me any closer to solution. It just allow me to handle mouse click event in managed code, but as i understand there is no way to open gadget context menu from silverlight control (managed code). – Denis Kucherov May 25 '12 at 08:58
  • i think that i need something like simulating right click event on transparent control, right after first right click. But i cant make it work and it seems to me very awkward. I can't believe that there is no better solution for that! – Denis Kucherov May 25 '12 at 09:04