Gabriel95 / scalafx

Automatically exported from code.google.com/p/scalafx
Other
0 stars 0 forks source link

KeyEvent doesn't have a defined keycode #62

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
For this code:

onKeyPressed = {e:KeyEvent =>
  println(e.code)
}

It always prints as "Undefined".

However, other members work correctly. For example, e.character is correct.

I want to match on e.code and hence I am stuck. I tried looking at the scalafx 
library code but everything looks correct to me.

Thanks for looking into it.

Original issue reported on code.google.com by harshad...@gmail.com on 28 May 2013 at 7:47

GoogleCodeExporter commented 8 years ago
My OS is Ubuntu 12.04 32bit, Running Oracle JVM 1.7.0_21

Original comment by harshad...@gmail.com on 28 May 2013 at 7:49

GoogleCodeExporter commented 8 years ago
Sorry, a little correction:

onKeyTyped exhibits the problematic behaviour. onKeyPressed works fine.

Original comment by harshad...@gmail.com on 28 May 2013 at 11:04

GoogleCodeExporter commented 8 years ago
This is not a bug, it is a correct behavior, according to JavaFX 2 API 
documentation:  "For key typed events, `code` is always KeyCode.UNDEFINED". See 
http://docs.oracle.com/javafx/2/api/javafx/scene/input/KeyEvent.html#getCode()

Original comment by jpsacha on 29 May 2013 at 3:11