[OpenLayers-Users] Right-click menu
Robert Buzink
post at robertbuzink.nl
Fri Feb 23 05:54:22 EST 2007
that's great. I want that :-). Could you tell me how you managed to
'properly
recongnize a right-click event in the MouseDefeaults.js file on mousedown'?
On 2/21/07, Graham Davis <gdavis at refractions.net> wrote:
>
> Well, I seem to have found the answer to my own question, so I thought
> I'd email it to the list just in case anyone else needs to know how.
>
> Basically there is an oncontextmenu event for DOM objects. You can
> assign this to a function and put any code you like in there, and then
> return false at the end to ensure the event stops and doesn't display
> the browser's context menu. So I added this to my map object to disable
> all browser context menus from appearing on the map like so:
>
> map.div.oncontextmenu = function noContextMenu(e) {return false;};
>
> Seems to work well in both IE and FF (haven't test Opera or on a Mac).
>
> --
> Graham Davis
> Refractions Research Inc.
> gdavis at refractions.net
>
>
>
> Graham Davis wrote:
>
> >I'm trying to implement a right-click menu on my map, similar to what
> >you see here: http://maps.ask.com/maps. I've been able to properly
> >recongnize a right-click event in the MouseDefeaults.js file on
> mousedown.
> >
> >My problem is that the browser's own right-click menu also appears, and
> >I need to disable or stop this. I've tried stopping the event from
> >propagating in the mousedown function after my code (and in the mouseup
> >function since that is when the browser menu seems to appear) however
> >this doesn't stop the browser menu from appearing.
> >
> >Has anyone been able to implement a right-click menu on their map that
> >properly disables the browser's right-click menu?
> >
> >Also, this might be of importance, but I'm using the vector branch of
> >code. I've noticed that when not using a vector layer, the right-click
> >menu on the map brings up the image menu as you have clicked on an image
> >in the map. When there is a vector layer overtop, right-clicking brings
> >up the standard browser menu where you can view source and whatnot, so
> >the menus are different. However, I think any fix for this would work
> >for both (and I have been testing everything I try both with and without
> >a vector layer). So far nothing works.
> >
> >
> >
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
--
Robert Buzink, website ontwerp en ontwikkeling
Sint-Pietersaalststraat 123
9000 Gent
+32 (0)9 33 00 267
+32 (0)487 548 414
post at robertbuzink.nl
robertbuzink.nl/webdesign
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20070223/220b8063/attachment.html
More information about the Users
mailing list