Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    how to call base class version of keypresshandler onKeyPress

    Hi,

    I am using a Tilegrid object to display contents. I wanted to do some customized event handling on enter key press. So, I attach and override the KeyPressHandler like below.

    Code:
    tileGrid.addKeyPressHandler (new KeyPressHandler() {
      @Override
      public void onKeyPress(KeyPressEvent event) {
        if (EventHandler.getKey().equals("Enter")) {
         //do something special here
        }
      }
    });
    But this code disables the default keyboard navigation of the tilegrid, and as a result arrow keys no longer work for moving between the elements of Tilegrid. I understand this could be because my code has overridden the key press event.

    I tried calling the base class version of keypress handler like this.

    Code:
      public void onKeyPress(KeyPressEvent event) {
        if (EventHandler.getKey().equals("Enter")) {
         //do something special here
        }
        else {
          super.onKeyPress(event);
        }
      }
    But this kind of code doesn't compile. So, what is the way to call the default version of keypress handler.

    Thanks in advance for the help.

    Note: This is similar to the issue raised here. http://forums.smartclient.com/showth...press+override

    environment:
    SmartGWT 3.0 with eclipse Helios

    EDIT:
    I realize that KeyPressHandler is an interface, and by doing addKeyPressHandler(), I am only attaching my implementation. But then how do I obtain a default behavior for those keys which I don't want to handle?
    Last edited by rv_nath; 14 Jun 2012, 22:21.
Working...
X