Summary: | [test case]dispatchEvent on TextEvents doesnt seem to work | ||
---|---|---|---|
Product: | [Applications] konqueror | Reporter: | Fredrik Johansson <fredrik> |
Component: | khtml event | Assignee: | Konqueror Developers <konq-bugs> |
Status: | RESOLVED DUPLICATE | ||
Severity: | normal | CC: | maksim |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | unspecified | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Attachments: | Test case attached |
Description
Fredrik Johansson
2005-09-24 21:47:33 UTC
I wrote a testpage for you. <html> <script language="javascript"> function testkey () { var e = window.event; // clear debug info debug("<h1>"+e.type+"</h1>", true); var obj = {}; for (ev in e) { obj[ev]= e[ev]; } // window.event.preventDefault(); // window.event.stopPropagation(); var txtev = document.createEvent("TextEvents"); txtev.initTextEvent("keydown",true, true, document.defaultView, 1, "A",97,0,true);//, 97, 0, true, false); /*void TextEvent::initTextEvent ( const DOMString & typeArg, bool canBubbleArg, bool cancelableArg, const AbstractView & viewArg, long detailArg, const DOMString & outputStringArg, unsigned long keyValArg, unsigned long virtKeyValArg, bool inputGeneratedArg, bool numPadArg ) */ debug("<br/><b>name: pageevent createev.</b><br/>"); for (o in obj) { debug (o+':'+obj[o]+' '+ txtev[o] + '<br/>'); }; txtev.srcElement = document.getElementById("fill"); //document.getElementById("test").dispatchEvent(txtev); /** * never gets dispatched?! what am I doing wrong */ document.getElementById("fill").dispatchEvent(txtev); //document.getElementById("test").dispatchEvent(txtev); debug('<br/>after dispatchEvent'); }; function testmouse (crashme) { // borrowed from http://www.opendarwin.org/pipermail/webkit-changes/2005-August/000564.html var e = window.event; // clear debuginfo debug("<h1>"+e.type+"</h1>", true); var ev = document.createEvent("MouseEvents"); // need to add s var view = document.defaultView; if (typeof crashme !='undefined') { view = null; } ev.initMouseEvent("click", true, true, view, 1, 1, 1, 1, 1, false, false, false, false, 0, document); if (view==null) { debug("Successfully created a mouse event object without a view and didn't crash."); }; // for some reason we cant iterate through these if we want dispatchEvent to work /* for (ev in e) { debug(ev+": "+e[ev]+"<br/>"); }; */ document.getElementById("divclicked").dispatchEvent(ev); }; function debug (str, clear) { if (arguments.length>1) { // we should clear debug info document.getElementById("debug").innerHTML = ""; }; var tmp = document.createElement("span"); tmp.innerHTML = str; document.getElementById("debug").appendChild(tmp); }; </script> <style type="text/css"> div#divclicked { color: blue; font-weight: bold; cursor: hand; } </style> <body> <input type="button" onclick="testmouse()" value="Create mouseevent"/><br/> <input type="button" onclick="testmouse(true)" value="Crash me" /><br/> <input type="text" id="test" onkeydown="testkey()" /> Every keydown in here should print "A" in input below, least thats what I'm hopeing for <br> <input type="text" id="fill" /> <div id="divclicked" onclick="alert('You have clicked on alert div with button '+window.event.button)" >alertdiv</div> <span id="debug"></span> </body> </html> Created attachment 12698 [details]
Test case attached
|