sojamo / controlp5

A gui library for processing.org
GNU Lesser General Public License v2.1
490 stars 142 forks source link

Bugfix keyCode bigger than mapped numKeys inside keyEvent method #128

Open ghost opened 6 years ago

ghost commented 6 years ago

Hello,

for some strange unknown reasons the method keyEvent inside of ControlWindow recieves a keyCode which cannot be handled by the keys boolean array of a size of only 1024. Then this error message is thrown and the application freeze.

java.lang.ArrayIndexOutOfBoundsException: 61443 at controlP5.ControlWindow.keyEvent(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at processing.core.PApplet$RegisteredMethods.handle(PApplet.java:1408) at processing.core.PApplet.handleMethods(PApplet.java:1610) at processing.core.PApplet.handleKeyEvent(PApplet.java:2946) at processing.core.PApplet.dequeueEvents(PApplet.java:2599) at processing.core.PApplet.handleDraw(PApplet.java:2437) at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1557) at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)

My approach was to check for the keyCode if it is bigger than numKeys (bigger than 1024) and exit the method if true. Maybe this is just a workaround and you have a better idea?! Anyway it fixed the bug.