Package ch.tatool.core.element.handler

Examples of ch.tatool.core.element.handler.KeyEventHandler


   */
  public void setupKeyEvents() {
    List<Object> keyEventHandlers = (List<Object>) ElementUtils.findHandlersInStackByType(executor.getExecutionContext(), KeyEventHandler.class);

    for (Object handler : keyEventHandlers) {
      final KeyEventHandler keyHandler = (KeyEventHandler) handler;

      Action keyAction = new AbstractAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
          if (executor != null) {
            logger.info("Key event triggered with code: " + KeyEvent.getKeyText(keyHandler.getKeyEvent()));
            keyHandler.triggerKeyEvent(keyHandler.getKeyEvent(), executor.getExecutionContext());
          }
        }
      };

      this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(keyHandler.getKeyEvent(), 0),"keyEvent_" + keyHandler.getKeyEvent());
      this.getRootPane().getActionMap().put("keyEvent_" + keyHandler.getKeyEvent(), keyAction);
    }
  }
View Full Code Here


    }
   
    public boolean dispatchKeyEvent(KeyEvent e) {
    if (e.getID() == KeyEvent.KEY_PRESSED) {
      if (getExecutionContext() != null) {
        KeyEventHandler keyEventHandler = (KeyEventHandler) ElementUtils.findHandlerInStackByType(getExecutionContext(), KeyEventHandler.class);
        if (keyEventHandler != null) {
          keyEventHandler.triggerKeyEvent(e.getKeyCode(), getExecutionContext());
        }
      }
    }
    // never consume the event...
    return false;
View Full Code Here

TOP

Related Classes of ch.tatool.core.element.handler.KeyEventHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.