Context Menu no longer displaying

18 posts, 0 answers
  1. Carolyn
    Carolyn avatar
    14 posts
    Member since:
    May 2006

    Posted 19 Jun 2009 Link to this post

    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.
  2. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 22 Jun 2009 Link to this post

    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.
  3. DevCraft banner
  4. Daniel Grünberger
    Daniel Grünberger avatar
    46 posts
    Member since:
    May 2008

    Posted 16 Sep 2009 Link to this post

    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
  5. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 16 Sep 2009 Link to this post

    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.
  6. Daniel Grünberger
    Daniel Grünberger avatar
    46 posts
    Member since:
    May 2008

    Posted 17 Sep 2009 Link to this post

    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

     

  7. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 17 Sep 2009 Link to this post

    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.
  8. Daniel Grünberger
    Daniel Grünberger avatar
    46 posts
    Member since:
    May 2008

    Posted 17 Sep 2009 Link to this post

    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
  9. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 18 Sep 2009 Link to this post

    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.
  10. Daniel Grünberger
    Daniel Grünberger avatar
    46 posts
    Member since:
    May 2008

    Posted 23 Sep 2009 Link to this post

    Hello Valeri,
    could you fix the zoom problem? If yes, how can I get a fixed version?
    br,
    Markus
  11. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 23 Sep 2009 Link to this post

    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.
  12. Daniel Grünberger
    Daniel Grünberger avatar
    46 posts
    Member since:
    May 2008

    Posted 28 Sep 2009 Link to this post

    Hi Valeri,
    just to check before I start downloading and testing, could you manage including this fix in the newest internal build?
    br,
    Markus
  13. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 01 Oct 2009 Link to this post

    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.
  14. Daniel Grünberger
    Daniel Grünberger avatar
    46 posts
    Member since:
    May 2008

    Posted 02 Oct 2009 Link to this post

    Hi,
    I tried, but without success :-(
    br,
    Markus
  15. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 06 Oct 2009 Link to this post

    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.
  16. balaji
    balaji avatar
    69 posts
    Member since:
    May 2009

    Posted 12 Oct 2009 Link to this post

    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.
  17. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 15 Oct 2009 Link to this post

    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.
  18. Kevin
    Kevin avatar
    1 posts
    Member since:
    Apr 2008

    Posted 11 Feb 2010 Link to this post

    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
  19. Kaloyan
    Admin
    Kaloyan avatar
    920 posts

    Posted 17 Feb 2010 Link to this post

    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.
Back to Top
DevCraft banner