Contextual Click in Non-Safari Browsers

Hey guys,

I spend most of my time developing using Safari. Safari does not have a contextual click menu that pops up on a right click/contextual click. I can generate my own and do so. To see an example, see:

http://youtu.be/mXVsNK0FnlM

The large menus in that video are contextual. This works great on Safari and also on Firefox, but on other browsers like Chrome and IE, this does not work so well as Chrome and IE have contextual menus of their own.

Anyone have any ideas for ways to work around this? Is there a way to suppress the browser’s contextual menu?

Thanks,

Jon

You mean this contextual menu that doesn’t pop up? Screenshot

Is there a way to add to the body tag through Xojo Web?

<body oncontextmenu="return false;">

Google says this should work for that. There are also some jQuery and JavaScript methods floating around, but this body one looks to be the most simple.

Not a Xojo Web expert, just trying to help :slight_smile:

You are right. Safari does have a contextual menu (and I am sure I use it all the time too…) :\ . I’ve just never seen it interfere with my app as Xojo must suppress it. Yes, I believe you can set a body tag in Xojo. I’ll try that. Thanks!

Now just how to do it for IE… :o

[quote=79750:@Jon Ogden]I spend most of my time developing using Safari. Safari does not have a contextual click menu that pops up on a right click/contextual click. I can generate my own and do so. To see an example, see:

http://youtu.be/mXVsNK0FnlM

The large menus in that video are contextual. This works great on Safari and also on Firefox, but on other browsers like Chrome and IE, this does not work so well as Chrome and IE have contextual menus of their own.[/quote]

Why not use Session.Browser as outlined in WebSession.Browser to know which client is used and employ native instead of your own when present ? You could even incorporate that in your method : if IE or Chrome then native else myown …

Well, a couple potential problems with this - First, I don’t think Xojo gives you access to the browser’s contextual menu. There is no contextual click event in WE. I had to figure this out on my own by checking which mouse button was pressed in the mouse down event.

Second, the contextual menus I generate sometimes are large. The contextual menus of the browsers even larger. So it would get really, really messy with browser commands and the commands I want to have all in one massive menu.

[quote=79754:@Tim Parnell]You mean this contextual menu that doesn’t pop up? Screenshot

Is there a way to add to the body tag through Xojo Web?

<body oncontextmenu="return false;">

Google says this should work for that. There are also some jQuery and JavaScript methods floating around, but this body one looks to be the most simple.

Not a Xojo Web expert, just trying to help :)[/quote]

OK. I figured out how to do this. You add a PageSource control to the web page. Then in that page source control you put:

<body><body oncontextmenu="return false;"></body>

Works great for Chrome. Not sure about IE.

I found some JavaScript on the web that should work but I’m not sure how to add a multi-line JavaScript to the page. Can someone provide any insight to this? I know how to do a single line but when I tried to do a multi-line script, I ended up with errors.

I have experimented with the method described at http://documentation.xojo.com/index.php/WebControl.ContextualMenu and it does trigger a contextual menu ?

Yes, Michael. That is what I do. However, it doesn’t give you access to append things to the browser’s contextual menu AFAIK.

What I show in my example are contextual menus created exactly as the docs describe. However, if you don’t suppress the browser’s contextual menu, you get both.