开发者

event.clientX is readonly?

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 开发者_JAVA百科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;


Ok, I found a solution here. Before passing the event to the contextMenu.show() function, I make a copy and pass it instead. This works a charm!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜