public class Button
extends java.lang.Object
EV3Key.ENTER.waitForPressAndRelease(); Sound.playTone(1000, 1);Notions: The API is designed around two notions: states (up / down) and events (press / release). It is said that a button is pressed (press event), if its state changes from up to down. Similarly, it is said that a button is released (release event), if its states changed from down to up. Thread Safety: All methods that return buttons states can be used safely from multiple threads, even while a call to one of the waitFor* methods active. However, it is not safe to invoke waitFor* methods in parallel from different threads. This includes the waitFor* methods of different buttons. For example EV3Key.ENTER.waitForPress() must not be invoked in parallel to EV3Key.ESCAPE.waitForPress() or the static EV3Key.waitForAnyEvent(). In case this is needed, it is strongly recommended that you write your own Thread, which waits for button events and dispatches the events to anyone who's interested.
Modifier and Type | Field and Description |
---|---|
private static Key |
ALL |
static Key |
DOWN
The Down button.
|
static Key |
ENTER
The Enter button.
|
static Key |
ESCAPE
The Escape button.
|
static Key |
LEFT
The Left button.
|
private static Logger |
log |
static Key |
RIGHT
The Right button.
|
static Key |
UP
The Up button.
|
Constructor and Description |
---|
Button() |
Modifier and Type | Method and Description |
---|---|
static int |
waitForAnyEvent()
Waits for some button to be pressed or released.
|
static int |
waitForAnyEvent(int timeout)
Waits for some button to be pressed or released.
|
static int |
waitForAnyPress()
Waits for some button to be pressed.
|
static int |
waitForAnyPress(int timeout)
Waits for some button to be pressed.
|
private static final Logger log
public static final Key ENTER
public static final Key LEFT
public static final Key RIGHT
public static final Key ESCAPE
public static final Key UP
public static final Key DOWN
private static final Key ALL
public static int waitForAnyEvent()
public static int waitForAnyEvent(int timeout)
timeout
- The maximum number of milliseconds to waitpublic static int waitForAnyPress(int timeout)
timeout
- The maximum number of milliseconds to waitpublic static int waitForAnyPress()