event.clientX is readonly?

Posted by Duracell on Stack Overflow See other posts from Stack Overflow or by Duracell
Published on 2010-05-27T02:38:10Z Indexed on 2010/05/27 2:41 UTC
Read the original article Hit count: 343

Working in IE 8, mostly, but trying to write a portable solution for modern browsers. Using telerik controls.

I'm catching the 'Showing' client-side event of the RadContextMenu and trying to adjust it's coordinates. The clientX, clientY and x,y members of the DOM event cannot be assigned a new value. Visual Studio breaks with a "htmlfile: Member not found" error.

My goal is to get a RadContextMenu to show inside a RadEditor when the user clicks in it (under certain conditions, this is a requirement from management). So I capture the onclick event for the RadEditor's content area (radEditor.get_document().body;). I then call show(evt) on the context menu, where 'evt' is the event object corresponding to the click event.

Because the RadEditor's content is in an IFRAME, you have to adjust the position of the click event before the context menu displays. This is done in the "Showing" event. However, I cannot assign a value to the members .clientX and friends. It's as if javascript has temporarily forgotten about integer + and += operators.

Is it possible that these members have become readonly/const at some point?

var evt = args.get_domEvent();

while (node) {
    evt.clientX += node.offsetLeft; //'Member not found' here.
    evt.clientY += node.offsetTop;
    node = node.offsetParent;
}

evt.clientY += sender.get_element().clientHeight;

© Stack Overflow or respective owner

Related posts about javascript-events

Related posts about operators