source: trunk/quest-core-events/src/main/java/de/ugoe/cs/quest/eventcore/gui/KeyPressed.java @ 786

Last change on this file since 786 was 786, checked in by sherbold, 12 years ago
  • code documentation
  • Property svn:executable set to *
File size: 2.0 KB
Line 
1
2package de.ugoe.cs.quest.eventcore.gui;
3
4import de.ugoe.cs.tasktree.keyboardmaps.VirtualKey;
5
6/**
7 * <p>
8 * Event type for pressing down a key.
9 * </p>
10 *
11 * @version 1.0
12 * @author Patrick Harms
13 */
14public class KeyPressed extends KeyInteraction {
15
16    /**
17     * <p>
18     * Id for object serialization.
19     * </p>
20     */
21    private static final long serialVersionUID = 1L;
22
23    /**
24     * <p>
25     * Constructor. Creates a new {@link KeyPressed} event type.
26     * </p>
27     *
28     * @see KeyInteraction#KeyInteraction(VirtualKey)
29     */
30    public KeyPressed(VirtualKey key) {
31        super(key);
32    }
33
34    /*
35     * (non-Javadoc)
36     *
37     * @see de.harms.attef.userinteraction.Interaction#getName()
38     */
39    public String getName() {
40        return "KeyPressed " + super.getKey();
41    }
42
43    /*
44     * (non-Javadoc)
45     *
46     * @see java.lang.Object#toString()
47     */
48    @Override
49    public String toString() {
50        return "pressing key " + super.getKey();
51    }
52
53    /*
54     * (non-Javadoc)
55     *
56     * @see de.harms.attef.userinteraction.Interaction#startsLogicalSequence()
57     */
58    public boolean startsLogicalSequence() {
59        // TODO handle lock keys correctly
60        return super.getKey().isCombinationKey();
61    }
62
63    /*
64     * (non-Javadoc)
65     *
66     * @see de.harms.attef.userinteraction.Interaction#finishesLogicalSequence()
67     */
68    public boolean finishesLogicalSequence() {
69        return false;
70    }
71
72    /*
73     * (non-Javadoc)
74     *
75     * @see java.lang.Object#equals(java.lang.Object)
76     */
77    @Override
78    public boolean equals(Object other) {
79        if (other instanceof KeyPressed) {
80            return (super.getKey() == ((KeyPressed) other).getKey());
81        }
82        else {
83            return false;
84        }
85    }
86
87    /*
88     * (non-Javadoc)
89     *
90     * @see java.lang.Object#hashCode()
91     */
92    @Override
93    public int hashCode() {
94        return super.getKey().hashCode();
95    }
96
97}
Note: See TracBrowser for help on using the repository browser.