KeyEvent.code does not contain a useful value in onKeyTyped events

XMLWordPrintable

    • Type: Bug
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: javafx
    • Environment:

      OS X, 10.5.5 JAva 1.6.0_7

      When trying to detect backspace keystrokes by using the onKeyXXX events on a group I find that the code value does not get populated with a useful value in onKeyTyped events.

      This means that detecting the keystrokes of a delete key being held down can't be done unless the programmer also provides and onKeyPressed handler and copies the KeyCode to their own variable for use in the onKeyTyped handler.

      Not sure if this is intended behavior.

      E.g

       onKeyPressed: function (e: KeyEvent):Void {
                      myCode = e.code;
                  }
                  onKeyTyped: function( e: KeyEvent ):Void {

                      if (myCode == KeyCode.VK_BACK_SPACE) {
                          if (this.text.length() > 0) {
                              this.text = this.text.substring(0, text.length() - 1)
                          }
                          
                      } else {
                          text += e.char;
                      }

                      if (textControl.layoutBounds.width > clipSize)
                      {
                          if (myCode == KeyCode.VK_BACK_SPACE) {
                              textControl.translateX += 5;
                          } else {
                              textControl.translateX -= 5;
                          }
                      }
                      println(this.text.length());
                      cursorPosition = textControl.layoutBounds.width
                  }
                 
                  }

            Assignee:
            Kevin Rushforth
            Reporter:
            Steven Herod (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: