This discussion is archived
1 Reply Latest reply: May 15, 2009 2:14 AM by 843851 RSS

HGraphicButton

843851 Newbie
Currently Being Moderated
Hi all,

if I add an actionListener to HGraphicButton, when it has focus, how can I distinguish "<- " key pressed from "->" key pressed? thanks
  • 1. Re: HGraphicButton
    843851 Newbie
    Currently Being Moderated
    In the keyPressed event listener the following code has to be written.

    It captures the keyevent and checks the type from the keycode, whether its a left, right, up or a down, and the hGraphicbutton source.

    public void keyPressed(KeyEvent keyEvent) {
              
              // TODO Auto-generated method stub

              if (keyEvent.getKeyCode() == HRcEvent.VK_LEFT&& keyEvent.getSource() == hGraphicButton1){
                   // TODO Auto-generated method stub
              }
              else if (keyEvent.getKeyCode() == HRcEvent.VK_RIGHT&& keyEvent.getSource() == hGraphicButton2){
         // TODO Auto-generated method stub
              }
    }