You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`java.awt.Paint` classes can now be compared using `DrawUtil.paintEquals`.
107
107
108
108
109
+
### Keyboard Improvements
110
+
FastJ's keyboard input API has improved by leaps and bounds since 1.4.0. Read on!
111
+
112
+
113
+
#### Better Keys Handling
114
+
In 1.4.0, checking for key equality was _fine_, but not very intuitive for situations such as determining if the right shift key is pressed:
115
+
116
+
```java title="Checking for Right Shift Key in FastJ 1.4.0"
117
+
if (Keyboard.isKeyDown(Keys.Shift)) {
118
+
// not what we want -- if no key location is specified, this type of key defaults to the left shift.
119
+
}
120
+
121
+
if (Keyboard.isKeyDown(Keys.Shift, KeyLocation.Left)) {
122
+
// this is what we want, but it makes life for beginners and the unsuspecting harder.
123
+
}
124
+
```
125
+
126
+
With FastJ 1.4.0, `Keys.Shift` is just an integer, meaning it can't safely store the key's location on the keyboard. In FastJ 1.5.0, `Keys` is now an enum and handles this well:
127
+
128
+
```java title="Checking for Right Shift Key in FastJ 1.5.0"
129
+
if (Keyboard.isKeyDown(Keys.RightShift)) {
130
+
// simpler to understand, and still achieves what we want!
131
+
}
132
+
```
133
+
134
+
Furthermore, the new Keys enum allows you to get a `Keys` instance based on a provided `java.awt.KeyEvent`_or_ provided key name, key code, and key location. We can use this to our advantage when dealing with raw `KeyEvent` instances, or building a key from scratch.
FastJ's `KeyboardActionListener` no longer directly passes `KeyEvent` instances -- FastJ is now equipped with its own `KeyboardEvent` classes!
148
+
149
+
These classes (`KeyboardStateEvent` and `KeyboardTypedEvent`) provide easy access to the key event and key name, and `KeyboardStateEvent` provides a `getKey` method which returns the corresponding `Keys` instance for the event.
150
+
151
+
Both `KeyboardStateEvent` and `KeyboardTypedEvent` also provide a `fromKeyEvent` method which allows you to create one from a `KeyEvent`:
152
+
```java title="Creating a KeyboardStateEvent/KeyboardTypedEvent from a KeyEvent"
The `LogicManager` class has been repurposed into an interface containing the basic needs for all logic managers. Two new managers implement this class:
0 commit comments