This is a migrated thread and some comments may be shown as answers.

Context Menu no longer displaying

17 Answers 226 Views
Menu
This is a migrated thread and some comments may be shown as answers.
Carolyn
Top achievements
Rank 1
Carolyn asked on 19 Jun 2009, 08:07 PM
Has anyone run into the scenario where, for whatever reason, the context menu no longer gets displayed on a right click? All other program functionality works just fine.

This has happened to me once before:  I added a drop shadow to a border control, and all of a sudden my context menus didn't pop up; remove the drop shadow and they're back.....

Any insight would be greatly appreciated.

17 Answers, 1 is accepted

Sort by
0
Valeri Hristov
Telerik team
answered on 22 Jun 2009, 12:43 PM
Hello Joe,

Please, check first if your Silverlight plugin is in windowless mode - it is required for the right-click support of RadContextMenu. Other thing that might break it is the browser zoom:


When the page is zoomed-in the right-click does not correctly report the mouse coordinates and the context menu does not open.

If the suggestions above do not help, please, open a new support ticket and send us a simple application that demonstrates the problem. We will respond with a solution as soon as possible.

Best wishes,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Daniel Knoll
Top achievements
Rank 1
answered on 16 Sep 2009, 01:26 PM
Hi,
when will this problem be solved? I just tried it with the latest Silverlight RadControls release, but still when zooming the browser the contextmenu get's the wrong position.
br,
Markus
0
Valeri Hristov
Telerik team
answered on 16 Sep 2009, 04:08 PM
Hi Markus,

Could you please, provide more information about your scenario? Browser, Silverlight runtime version, RadControls for Silverlight version, etc. If possible please, open a new support ticket and send us a simple application + steps to reproduce the problem and we will respond with a suggestion or bug fix as soon as possible.

All the best,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Knoll
Top achievements
Rank 1
answered on 17 Sep 2009, 08:10 AM
Hi Valeri,
thank you for fast response!

Silverlight:         2.0
RadControls:     2009.1.0312.1020 (but is the same with RadControls_for_Silverlight_2009_2_0812).
Browser:          IE 8 (on Windows 7)

Constructor of page:
...

// Adds support for opening the context menu by right mouse button click

 

HtmlPage.Document.AttachEvent("oncontextmenu", this.OnContextMenu);

 

...

Handler of contextmenu:

///

 

<summary>

 

/// Occers, when the user clicks the right mouse button.

 

/// </summary>

 

/// <param name="sender">The sender of the event.</param>

 

/// <param name="e">EventArgs of the event.</param>

 

private void OnContextMenu(object sender, HtmlEventArgs e)

{

 

var elements = VisualTreeHelper.FindElementsInHostCoordinates(new Point(e.OffsetX, e.OffsetY), this).ToList();

 

this.LoadContextMenu(elements);   // here menuitems are displayed/hidden accoring to the element the menu is called for

e.PreventDefault();

}

When executing this code with zoom 100% evereything works fine, the contextmenu opens for the correct elements. When zoomlevel is different (e.g. 125%) the contextmenu opens over completely wrong elements.

br,
Markus

 

0
Valeri Hristov
Telerik team
answered on 17 Sep 2009, 11:34 AM
Hello Markus,

In version 2, Silverlight does not report correctly the mouse coordinates when the browser zoom is on. I suppose this is the reason for the problem. On the other hand, I see that you are using custom code to open the context menu - why don't you let the control to determine when and where to display itself?

Sincerely yours,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Knoll
Top achievements
Rank 1
answered on 17 Sep 2009, 12:09 PM
Hi,
in our custom code the opening position is not modified. We need custom code here as some context menu items are displayed depending on the element the context menu is opend for (i.e. the element, the right mouse button is clicked on).
Do you know another way to determine the elements the context menu is opened on?
br,
Markus
0
Valeri Hristov
Telerik team
answered on 18 Sep 2009, 07:01 AM
Hello Markus,

I just checked our online samples, it seems that there is still a problem - when a popup is opened, the browser zoom is reset, which results in wrong coordinates. I found and fixed the root of the problem. The upcoming internal build today will contain the fix.

All the best,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Knoll
Top achievements
Rank 1
answered on 23 Sep 2009, 12:42 PM
Hello Valeri,
could you fix the zoom problem? If yes, how can I get a fixed version?
br,
Markus
0
Valeri Hristov
Telerik team
answered on 23 Sep 2009, 01:02 PM
Hello Markus,

We failed to release an internal build the last friday, I apologize for that. This friday's build will be released on time. If you need the fix earlier, please, open a new support ticket and we will attach the assemblies there.

Sincerely yours,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Knoll
Top achievements
Rank 1
answered on 28 Sep 2009, 02:53 PM
Hi Valeri,
just to check before I start downloading and testing, could you manage including this fix in the newest internal build?
br,
Markus
0
Kaloyan
Telerik team
answered on 01 Oct 2009, 09:39 AM
Hello Markus Unterauer,

You can download the latest internal build and give it a try. The files are located under your account's Downloads section.

Let us know how this goes.

Sincerely yours,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Daniel Knoll
Top achievements
Rank 1
answered on 02 Oct 2009, 07:09 AM
Hi,
I tried, but without success :-(
br,
Markus
0
Valeri Hristov
Telerik team
answered on 06 Oct 2009, 02:40 PM
Hi Markus,

I created a simple application that uses the internal RadContextMenu mechanism for opening and getting the element that is below, that appears to be working properly when the browser is zoomed. I didn't removed the assemblies (Trial version because this is a forum) in order to allow you to test the application as it is on my side.

Kind regards,
Valeri Hristov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
balaji
Top achievements
Rank 1
answered on 12 Oct 2009, 06:49 AM
Hi
Am also getting the same problem that my context menu is not displaying whenever i used rightclick of an item.
My Telerik version of dll is :2009.2.701.1020
and my silverlight version is 3 and rad is q2
Instead am getting silverlight context menu as "Silverlight".
Would that be a problem.
Thanks
<UserControl x:Class="ProdShowcase.test1" 
   xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
   xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" 
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"     
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"    
    Width="647" Height="285">  
   <StackPanel x:Name="LayoutRoot">  
         
            <telerikNavigation:RadContextMenu.ContextMenu> 
                <telerikNavigation:RadContextMenu   
                    Opened="RadContextMenu_Opened_1">  
                </telerikNavigation:RadContextMenu> 
            </telerikNavigation:RadContextMenu.ContextMenu> 
 
            <Grid Width="100" Height="100" Background="Red" HorizontalAlignment="Left" /> 
 
            <Grid Width="100" Height="100" Background="Blue" HorizontalAlignment="Left" /> 
 
            <TextBlock x:Name="text" /> 
            
 
            <Grid Width="100" Height="100" Background="Red" HorizontalAlignment="Left" /> 
 
            <Grid Width="100" Height="100" Background="Blue" HorizontalAlignment="Left" /> 
         
  </StackPanel> 
     
      
</UserControl> 
 

My cs code file is this
using System;  
using System.Windows;  
using System.Windows.Controls;  
using Telerik.Windows.Controls;  
using Telerik.Windows;  
using System.Windows.Media.Imaging;  
using System.Windows.Media;  
using System.Windows.Shapes;  
namespace ProdShowcase  
{  
    public partial class test1 : UserControl  
    {  
         
 
 
        public test1()  
        {  
            InitializeComponent();  
 
 
            //rectangle.SetValue(RadContextMenu.ContextMenuProperty, contextMenu);  
             
 
        }  
        private void RadContextMenu_ItemClick(object sender, Telerik.Windows.RadRoutedEventArgs e)  
        {  
            var rect = (sender as RadContextMenu).GetClickedElement<Grid>();  
            if (rect != null)  
            {  
                this.text.Text = (e.OriginalSource as RadMenuItem).Header.ToString();  
            }  
        }  
 
        private void RadContextMenu_Opened(object sender, RoutedEventArgs e)  
        {  
            var contextMenu = sender as RadContextMenu;  
 
            var rect = contextMenu.GetClickedElement<Grid>();  
            if (rect != null)  
            {  
                contextMenu.Items.Clear();  
 
                if ((rect.Background as SolidColorBrush).Color.Equals(Colors.Red))  
                {  
                    this.LoadRedItems(contextMenu);  
                }  
                else  
                {  
                    this.LoadBlueItems(contextMenu);  
                }  
            }  
            else  
            {  
                contextMenu.IsOpen = false;  
                this.text.Text = "Please, click on a rectangle";  
            }  
        }  
 
        private void LoadRedItems(RadContextMenu contextMenu)  
        {  
            contextMenu.Items.Add(new RadMenuItem() { Header = "Red 1" });  
            contextMenu.Items.Add(new RadMenuItem() { Header = "Red 2" });  
            contextMenu.Items.Add(new RadMenuItem() { Header = "Red 3" });  
        }  
 
        private void LoadBlueItems(RadContextMenu contextMenu)  
        {  
            contextMenu.Items.Add(new RadMenuItem() { Header = "Blue 1" });  
            contextMenu.Items.Add(new RadMenuItem() { Header = "Blue 2" });  
            contextMenu.Items.Add(new RadMenuItem() { Header = "Blue 3" });  
        }  
 
        private void RadContextMenu_Opened_1(object sender, RoutedEventArgs e)  
        {  
 
        }  
 
 
 
 
    }  
}  
 
 if  i try to right click the red grid am getting only silverlight menu rathern than my desired context menu.
0
Kaloyan
Telerik team
answered on 15 Oct 2009, 10:33 AM
Hello balaji,

The RadContextMenu is working only if you set the WindowsLess mode to true in your Silverlight definition of your startup html page.

<object data="data:application/x-silverlight-2," id="Xaml1" type="application/x-silverlight-2"
           width="100%" height="100%">
           <param name="source" value="Examples/Examples.CS.xap" />
           <param name="onerror" value="onSilverlightError" />
           <param name="background" value="#084E85" />
           <param name="Windowless" value="true" />
           <param name="minRuntimeVersion" value="3.0.40624.0" />
</object>

Hope this helps.

Regards,
Kaloyan
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Kevin
Top achievements
Rank 1
answered on 11 Feb 2010, 05:43 PM
We are experiencing problems using the context menu in our application on some Firefox browsers. The same code seems to work fine on IE. The problem seems to exist on both Firefox v3.5.7 and v3.6. The frustrating part is the context menu works fine on like 9 out of 10 people's systems running Firefox. On the systems that have problems, the context menu will not come up for the tree node that they right mouse-clicked on. It seems the VisualTreeHelper.FindElementsInHostCoordinates() method  is not using the appropriate mouse coordinates? The user needs to click approximately two rows below the tree node that they actually want to show the context menu for.

Our code works fine for me in either IE or Firefox, so it is difficult for me to troubleshoot.  For the most part we use code very similar to that found in this article, Reusing and customizing a single ContextMenu on a TreeView with RadControls for Silverlight.

Interestingly enough, I do experience the same or at least a similar context menu problem using the source code, ContextMenuInTreeView2.zip, provided in the article when using Firefox; it works fine with IE. I found that in order to make it work for me in Firefox, I had to use a general tranform by changing this code:

        private T FindElementAt<T>(Point coordinates) where T : UIElement
        {
                return (T)VisualTreeHelper.FindElementsInHostCoordinates(coordinates, this)
                     .FirstOrDefault((element) => element is T);
        }

to this:

private

 

T FindElementAt<T>(Point coordinates) where T : UIElement

 

{

 

GeneralTransform generalTransform = TreeView.TransformToVisual(Application.Current.RootVisual);

 

 

Point childToParentCoordinates = generalTransform.Transform(coordinates);

 

 

T firstOrDefault = (T)

VisualTreeHelper.FindElementsInHostCoordinates(childToParentCoordinates, this).FirstOrDefault(

 

(element) => element

is T);

 

 

return firstOrDefault;

 

}


With the original code, the "New Child" would be added to the wrong parent. It would add it to the parent above. Here are the steps that I performed:

1. Expand "Item 3"
2. Right mouse click on "Item 3.3"
3. Select "New Child" from the context menu

The "New Child" node gets added to "Item 3.2"; not "Item 3.3" as expected.

Furthermore, I noticed that if I bring up the context menu by clicking on the bottom portion of the "Item 3.3" tree node, the "New Child" node gets added to "Item 3.3". However, if I bring up the context menu by clicking on the middle or top portion of the "Item 3.3" tree node, the child node is added to the wrong parent.

So, I thought great, I will add the general transform code that worked in this example code to our code, but unfortunately it still doesn't seem to overcome the problem :(

Is this a known problem or is there anything else that you can suggest that I try?

Thanks,

Kevin

We are using Telerik DLL version:     2009.3.1314.1030
0
Kaloyan
Telerik team
answered on 17 Feb 2010, 09:11 AM
Hi Kevin,

We are sorry for the inconvenience caused. I did some testing following you points order and did not succeeded in reproducing the described issues. I performed the test with the assemblies that will be included for the Q1 2010 Beta release this week. So I can advice you to grab them from your personal account and give us a back info in case the issues appear again. The downloading package will be available at the and of this week.

All the best,
Kaloyan
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Menu
Asked by
Carolyn
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Daniel Knoll
Top achievements
Rank 1
Kaloyan
Telerik team
balaji
Top achievements
Rank 1
Kevin
Top achievements
Rank 1
Share this question
or