Is there a recommended method of getting context menus working on Macs? I don't have a Mac to test on at the moment, but understand that they don't support 'windowless' or right-click. Is this correct? If so, what's the best way of getting a context menu working? I'd like to use the same code for windows and macs, so need something that seems natural on the windows platform too.
Thanks, James.
6 Answers, 1 is accepted
You are right, that on Mac the right-click support is missing. Unfortunately the best cross-platform option at the moment would be opening the context menu on left-click + modifier key, for example Ctrl. However, this does not seem very intuitive for the Windows users. Since this is a platform limitation, we can't do much, except keep searching for Mac specific hack that will enable us to catch the right click.
Kind regards,
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.
Thanks for your answer. You're right - ctrl+left-click isn't going to please my Windows users! Is it possible to tie both events up to the menu? i.e. to have the ContextMenu appear to ctrl+left click and right-click? Mac users would ctrl+left-click for now and Windows users would have the choice of either.
Thanks for your help, James.
I will need some time to prepare a sample, opening the context menu at the right position appears to be harder than I thought. I hope that I will be able to send you an example by Tuesday next week. Thank you for your patience.
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.
Hi guys,
Please, find attached the promised sample.
There are two things to mention - browser detection and context menu configuration:
- Since the Windowless mode is required for the right-click functionality to operate properly, but it is not supported in Safari, I added the following code in the ASPX page:
<object data="data:application/x-silverlight-2," id="Xaml1" type="application/x-silverlight-2" width="100%" height="100%">
<param name="source" value="ClientBin/ContextMenuDifferentEventNameOnMacAndPC.xap" />
<param name="background" value="#FFFFFF" />
<% if (!Request.Browser.IsBrowser("Safari")) { %>
<param name="Windowless" value="true" />
<% } %>
<param name="minRuntimeVersion" value="2.0.30818.0" />
</object>
If you are not very much into ASP.NET, this is a server-side check that detects Safari and renders, or does not render the Windowless parameter, depending on the browser. This trick will not work in HTML page, so if you need to host your Silverlight plug-in in a HTML page, you will have to search for another workaround.
From now on the context menu configuration is easy:
bool rightClickAllowed = Application.Current.Host.Settings.Windowless;
if (rightClickAllowed)
{
// By default RadContextMenu will open on Right click.
this.InstructionsText.Text = "Right click the red rectangle to open a context menu";
}
else
{
// Set EventName and ModifierKey for Mac users
this.ContextMenu1.ModifierKey = ModifierKeys.Control;
this.ContextMenu1.EventName = "MouseLeftButtonDown";
this.InstructionsText.Text = "Ctrl+LeftClick the red rectangle to open a context menu";
}
I hope this helps.
Greetings,
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.
Thanks for your answer and example. I've added your code to my aspx page and the app runs fine. I'll be getting a mac next week for testing...
Thanks for your help, James.