Hello everybody,
I am using FF3 embedded in a eyetracker-controlled app. I am able to
detect the coords of a given DOM node on screen and then synthesize
some mouse events to simulate a mouse click. Exactly, I perform
something like this:
nsCOMPtr<nsIDOMWindow> domWindow;
mWebBrowser->GetContentDOMWindow(getter_AddRefs(domWindow));
nsCOMPtr<nsIDOMWindowUtils> windowUtils(do_GetInterface
(domWindow));
float left, top, right, bottom;
GetDOMNodeCoords(DOMNodeToClick, left, top, right, bottom);
float centerX = (left + right) / 2.0;
float centerY = (top + bottom) / 2.0;
windowUtils->SendMouseEvent(NS_LITERAL_STRING("mousemove"),
centerX, centerY, 0, 0, 0);
windowUtils->SendMouseEvent(NS_LITERAL_STRING("mousedown"),
centerX, centerY, 0, 1, 0);
windowUtils->SendMouseEvent(NS_LITERAL_STRING("mouseup"), centerX,
centerY, 0, 1, 0);
this works, and I remember I have read somewhere that this also
synthesizes a "click" event and sends it to the DOM node at those
coordinates. In fact, I have also a domWindow event listener, and if I
try this stuff on a simple HTML-only page, I can see the "click" event
being dispatched and received by my event listener handler. So far so
good.
Fact is, for SOME sites, this does not happen, i.e. Facebook. In
FaceBook, no matter where I synthesize these events, my event listener
NEVER receives any "click" event. On other sites, like the Google
homepage, I get those "click" events in my listener for some DOM
nodes, and I don't for others (like the "more" drop-down).
I mean, everything works, nearly. I can navigate, my menus correctly
open and close, and probably I don't get the events because something
somewhere in the sites frameworks intercepts them. Would not be a
problem... if Facebook did not have that #%&$! "Search" button, on the
home, right top. It is an A(nchor) node, no href, an onclick
javascript handler, class = "qsearch_button", title= "Search
Facebook". Visually, is the square one with the magnifying glass
inside. No inner text, also.
This WILL NOT WORK. When I send synthesized mouse events, the "click"
event is NOT generated, my event listener does not receive any
"click", and the "onclick" handler of the search button is not called.
Nothing happens, obviously. If I explicitly send a "click" to the DOM
node (with a DispatchEvent etc etc) the search works. Obviously, if I
always synthesize a click, I might break all the OTHER "normal" sites,
which now receive TWO clicks (in fact the Google "more" dropdown stops
working).
At this point I must admit I am puzzled. Any advice, anybody? Do
really the "click" are intercepted by some javascript/framework
machinery? And how the FB search button onclick handler is supposed to
work, if the click message is intercepted somewhere and never
delivered? I admit this is beyond my web/scripting knowledge, so if
anybody has any idea, please help me.
thanks,
Aaron Brancotti / Babele Dunnit
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding