华廷FireEvent不及格事件属性在FireFox [英] WatiN FireEvent not passing event properties in FireFox

查看:133
本文介绍了华廷FireEvent不及格事件属性在FireFox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这已经记录为臭虫sourceforge上虽然现在被删除。

This had been logged as a bug in sourceforge though now deleted.

我使用的是Firefox 3.6的关联jssh。

I'm using FireFox 3.6 with associated jssh.

我可以看到萤火虫的事件属性没有被设置的。我试图拖动和低于

I can see in Firebug that the Event Properties are not being set. I'm trying to drag and drop with code below

var mouseDownEvent = new NameValueCollection 
                         {{"button", "1"}, {"clientX", "0"}, {"clientY", "0"}};
firstStoryRow.FireEventNoWait("onmousedown", mouseDownEvent);

有的 的解决方法传递这些属性,但它们不是很不是很好。

There are workarounds for passing these properties but not they're not nice.

请问任何人都知道,如果这是在华廷或真正限制什么我做错了吗?

Does anyone know if this is an genuine limitation within WatiN or something I'm doing wrong?

推荐答案

这的确是一个缺点火狐的实现。所有给定的参数/值将被忽略鼠标事件。这应该是固定的,并不难。我会重新SourceForge上的问题。

This is indeed a shortcoming in the FireFox implementation. All the given parameters/values are ignored for mouse events. This should be fixed and is not that hard. I will reopen the issue on SourceForge.

为了使这项工作,你可以运行此代码,这是华廷实际上是为你做:

To make this work you could run this code, which is what WatiN is actually doing for you:

var jscriptref = firstStoryRow.GetJavascriptElementReference();

var fireeventcode = string.Format("var event = {0}.ownerDocument.createEvent('MouseEvents');",jscriptref);

// Params for the initMouseEvent:
// 'type', bubbles, cancelable, windowObject, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget )
fireeventcode += "event.initMouseEvent('mousedown', true, true, null, 0, 0, 0, 0, 0, false, false, false, false, 1, null);";
fireeventcode += string.Format("var res = {0}.dispatchEvent(event);", jscriptref);
fireeventcode += "if(res){true;}else{false;};";

// make it a NoWait call by wrapping it in a timer call.
fireeventcode = JSUtils.WrapCommandInTimer(fireeventcode);

var result = browser.Eval(fireeventcode);

如果结果=='真'一切顺利。
希望这将​​有助于现在,但是这需要固定在下一版本中。

If result == 'true' all went well. Hope this will help for now, but this needs to be fixed in the next release.

吉荣

这篇关于华廷FireEvent不及格事件属性在FireFox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆