From c81521a90d5f70d490d6d8825b03c577fb3d6d5b Mon Sep 17 00:00:00 2001 From: Pin Zhang Date: Wed, 12 Nov 2014 15:22:03 +0800 Subject: [PATCH] Fix LWUIT key release issue. `com.sun.lwuit.Display.keyReleased` is never been called which causes `com.sun.lwuit.Form.keyRepeated` is invoked repeately. --- midp/midp.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/midp/midp.js b/midp/midp.js index 1106174f..79d7ef02 100644 --- a/midp/midp.js +++ b/midp/midp.js @@ -872,12 +872,21 @@ MIDP.suppressKeyEvents = false; MIDP.keyPress = function(keyCode) { if (!MIDP.suppressKeyEvents) MIDP.sendNativeEvent({ type: MIDP.KEY_EVENT, intParam1: MIDP.PRESSED, intParam2: keyCode, intParam3: 0, intParam4: MIDP.displayId }, MIDP.foregroundIsolateId); -} +}; + +MIDP.keyRelease = function(keyCode) { + if (!MIDP.suppressKeyEvents) + MIDP.sendNativeEvent({ type: MIDP.KEY_EVENT, intParam1: MIDP.RELEASED, intParam2: keyCode, intParam3: 0, intParam4: MIDP.displayId }, MIDP.foregroundIsolateId); +}; window.addEventListener("keypress", function(ev) { MIDP.keyPress(ev.which); }); +window.addEventListener("keyup", function(ev) { + MIDP.keyRelease(ev.which); +}); + Native.create("com/sun/midp/events/EventQueue.getNativeEventQueueHandle.()I", function() { return 0; });