Ticket #4740: 4740.patch
| File 4740.patch, 3.9 kB (added by becky, 7 months ago) |
|---|
-
Users/bgibson/Documents/workspace/trunk/dijit/_Widget.js
387 387 // summary: 388 388 // Connects specified obj/event to specified method of this object 389 389 // and registers for disconnect() on widget destroy. 390 // Special event: "ondijitclick" triggers on a click or enter-down or space-up 390 // Special event: "ondijitclick" triggers on a click or space-up, enter-down in IE 391 // or enter press in FF (since often can't cancel enter onkeydown in FF) 391 392 // Similar to dojo.connect() but takes three arguments rather than four. 392 393 var handles =[]; 393 394 if(event == "ondijitclick"){ … … 395 396 if(!this.nodesWithKeyClick[obj.nodeName]){ 396 397 handles.push(dojo.connect(obj, "onkeydown", this, 397 398 function(e){ 398 if( e.keyCode == dojo.keys.ENTER){399 if(!dojo.isFF && e.keyCode == dojo.keys.ENTER){ 399 400 return (dojo.isString(method))? 400 401 this[method](e) : method.call(this, e); 401 402 }else if(e.keyCode == dojo.keys.SPACE){ … … 411 412 this[method](e) : method.call(this, e); 412 413 } 413 414 })); 415 if (dojo.isFF){ 416 handles.push(dojo.connect(obj, "onkeypress", this, 417 function(e){ 418 if(e.keyCode == dojo.keys.ENTER){ 419 return (dojo.isString(method))? 420 this[method](e) : method.call(this, e); 421 } 422 })); 423 } 414 424 } 415 425 event = "onclick"; 416 426 } -
Users/bgibson/Documents/workspace/trunk/dijit/tests/ondijitclick.html
44 44 w.clickCount = 0; 45 45 w.domNode.dispatchEvent(e); 46 46 t.is(1, w.clickCount); 47 } 47 } 48 48 } 49 49 }, 50 50 { 51 name: "ondijitclick fires once on an enter-key-down ",51 name: "ondijitclick fires once on an enter-key-down except in FF", 52 52 runTest: function(t){ 53 53 var w = dijit.byId("widget1"); 54 54 if (dojo.isSafari){ // safari has error … … 63 63 w.domNode.focus(); 64 64 w.clickCount = 0; 65 65 w.domNode.dispatchEvent(e); 66 t.is(1, w.clickCount); 66 if (!dojo.isFF){ 67 t.is(1,w.clickCount); 68 }else{ 69 t.is(0, w.clickCount); 70 } 71 } 72 } 73 }, 74 { 75 name: "ondijitclick fires once on an enter-key-press in FF", 76 runTest: function(t){ 77 var w = dijit.byId("widget1"); 78 if (dojo.isSafari){ // safari has error 79 this.name += " * SKIPPED *"; 80 return; 81 } 82 83 // simulate enter down 84 if (document.createEvent && !dojo.isSafari){ 85 var e = document.createEvent("KeyboardEvent"); 86 e.initKeyEvent("keypress",true,true,null,false,false,false,false,13,0); 87 w.domNode.focus(); 88 w.clickCount = 0; 89 w.domNode.dispatchEvent(e); 90 if (dojo.isFF){ 91 t.is(1, w.clickCount); 92 }else{ 93 t.is(0, w.clickCount); 94 } 95 } 96 } 97 }, 98 { 99 name: "ondijitclick does not fire on a space-key-down", 100 runTest: function(t){ 101 var w = dijit.byId("widget1"); 102 if (dojo.isSafari){ // safari has error 103 this.name += " * SKIPPED *"; 104 return; 105 } 106 107 // simulate space up 108 if (document.createEvent){ 109 var e = document.createEvent("KeyboardEvent"); 110 e.initKeyEvent("keydown",true,true,null,false,false,false,false,32,0); 111 w.domNode.focus(); 112 w.clickCount = 0; 113 w.domNode.dispatchEvent(e); 114 t.is(0, w.clickCount); 67 115 } 68 116 } 69 117 },