View Full Version : [SOLVED] Capture mouse position to show contextmenu

30 Jun 2010, 7:54 AM
I have a problem with capturing the mouse event to place the context menu. What I am trying to do is on a right click of the mouse on the map, it is supposed to return an event, but it doesn't, just that the event fired. Although, in the Google Maps API, it says it returns an Event (whatever that may be, I'm assuming a mousedown event), it doesn't return anything.

google.maps.event.addListener(marker, "rightclick", digitizer.onContextMenu.createDelegate(mapPanel, marker, true));

// Somewhere else in code
map.digitizer.onContextMenu = function (e, marker) {
// Create the menu
if (!this.digitizer.menu) {
var items = [{
itemId: "delete",
text: "Delete",
scope: this,
handler: this.digitizer.deletePoint
this.digitizer.menu = new Ext.menu.Menu({
items: items
this.digitizer.menu.showAt([event.screenX, event.screenY]);
The arguments passed is 1. Which means that events was not passed.

So my question is how do I capture the mouse position? I know this is a simple Javascript question, but any help is mucho appreciated.

30 Jun 2010, 8:23 AM
Never mind.


Shashwat Rohilla
6 Mar 2012, 11:28 PM
You can try this:

var X = e.browserEvent.clientX;
var Y = e.browserEvent.clientY;
this.digitizer.menu.showAt([X, Y]);