1 /*******************************************************************************
\r
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
\r
3 * in Industry THTH ry.
\r
4 * All rights reserved. This program and the accompanying materials
\r
5 * are made available under the terms of the Eclipse Public License v1.0
\r
6 * which accompanies this distribution, and is available at
\r
7 * http://www.eclipse.org/legal/epl-v10.html
\r
10 * VTT Technical Research Centre of Finland - initial API and implementation
\r
11 *******************************************************************************/
\r
14 * @author Toni Kalajainen
\r
16 package org.simantics.scenegraph.g2d.events.adapter;
\r
18 import java.awt.event.KeyEvent;
\r
19 import java.awt.event.KeyListener;
\r
21 import org.simantics.scenegraph.g2d.events.EventDebugPolicy;
\r
22 import org.simantics.scenegraph.g2d.events.IEventHandler;
\r
23 import org.simantics.scenegraph.g2d.events.IEventQueue;
\r
24 import org.simantics.scenegraph.g2d.events.KeyEvent.KeyPressedEvent;
\r
25 import org.simantics.scenegraph.g2d.events.KeyEvent.KeyReleasedEvent;
\r
28 public class AWTKeyEventAdapter extends AbstractEventAdapter implements KeyListener {
\r
30 private final boolean DEBUG = EventDebugPolicy.AWT_KEY_EVENT_ADAPTION;
\r
32 private final boolean IGNORE_CONSUMED_EVENTS = false;
\r
34 public AWTKeyEventAdapter(Object sender, IEventHandler delegator) {
\r
35 super(sender, delegator);
\r
38 public AWTKeyEventAdapter(Object sender, IEventQueue queue) {
\r
39 super(sender, queue);
\r
43 public void keyPressed(KeyEvent e) {
\r
44 if (IGNORE_CONSUMED_EVENTS) {
\r
45 if (e.isConsumed()) {
\r
47 System.out.println("AWT key pressed but already consumed: " + e);
\r
52 System.out.println("AWT key pressed: " + e);
\r
54 new KeyPressedEvent(sender, e.getWhen(), e.getKeyChar(), e.getKeyCode(), e.getModifiers()));
\r
58 public void keyReleased(KeyEvent e) {
\r
59 if (IGNORE_CONSUMED_EVENTS) {
\r
60 if (e.isConsumed()) {
\r
62 System.out.println("AWT key released but already consumed: " + e);
\r
67 System.out.println("AWT key released: " + e);
\r
69 new KeyReleasedEvent(sender, e.getWhen(), e.getKeyChar(), e.getKeyCode(), e.getModifiers()));
\r
73 public void keyTyped(KeyEvent e) {
\r
74 if (IGNORE_CONSUMED_EVENTS) {
\r
75 if (e.isConsumed()) {
\r
77 System.out.println("AWT key typed but already consumed: " + e);
\r
81 System.out.println("AWT key typed: " + e);
\r
83 new KeyPressedEvent(sender, e.getWhen(), e.getKeyChar(), e.getKeyCode(), e.getModifiers()));
\r