From a51cf1a131afcc4ad750c9a775965481cd435b87 Mon Sep 17 00:00:00 2001 From: Kacper Walanus Date: Tue, 11 Dec 2012 21:28:32 +0100 Subject: [PATCH] keydown before fill --- autologger.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/autologger.js b/autologger.js index d8375c4..5b735c0 100644 --- a/autologger.js +++ b/autologger.js @@ -171,6 +171,7 @@ var infoDivId = '__AL109'+this.name; that.addEventListener('dblclick', function(){ + that.simulateKeyDown(); var value = AL.inputs.valueToPut(type, that); that.value = value; @@ -194,11 +195,31 @@ var valueToPut = AL.inputs.valueToPut(type, this); if(!valueToPut.match('Set your')) { + this.simulateKeyDown(); this.value = valueToPut; } } }, + HTMLInputElement.prototype.simulateKeyDown = function() { + var keyboardEvent = document.createEvent("KeyboardEvent"); + var initMethod = typeof keyboardEvent.initKeyboardEvent !== 'undefined' ? "initKeyboardEvent" : "initKeyEvent"; + + keyboardEvent[initMethod]( + "keydown", // event type : keydown, keyup, keypress + true, // bubbles + true, // cancelable + window, // viewArg: should be window + false, // ctrlKeyArg + false, // altKeyArg + false, // shiftKeyArg + false, // metaKeyArg + 40, // keyCodeArg : unsigned long the virtual key code, else 0 + 0 // charCodeArgs : unsigned long the Unicode character associated with the depressed key, else 0 + ); + this.dispatchEvent(keyboardEvent); + }, + NodeList.prototype.toArray = function() { var htmlElements = [] for(var i=0; i