package greenfoot.vmcomm;
| A command or event from the server VM to the debug VM, such
| as keyboard/mouse event, Run, Reset, etc
|
public class Command
{
|
| Key events. Followed by one integer which is the key code
| (using the JavaFX KeyCode enum's ordinal method), then the rest
| are integer codepoints from the string of the key text.
|
public static final int KEY_DOWN = 1;
public static final int KEY_UP = 2;
public static final int KEY_TYPED = 3;
|
| Mouse events. Followed by four integers:
| X pos, Y pos, button index, click count
|
public static final int MOUSE_CLICKED = 11;
public static final int MOUSE_PRESSED = 12;
public static final int MOUSE_DRAGGED = 13;
public static final int MOUSE_RELEASED = 14;
public static final int MOUSE_MOVED = 15;
public static final int MOUSE_EXITED = 16;
|
| Commands or requests. Unless otherwise specified,
| followed by no integers.
|
public static final int COMMAND_RUN = 21;
public static final int COMMAND_CONTINUE_DRAG = 22;
public static final int COMMAND_END_DRAG = 23;
public static final int COMMAND_PAUSE = 24;
public static final int COMMAND_ACT = 25;
public static final int COMMAND_INSTANTIATE_WORLD = 26;
public static final int COMMAND_ANSWERED = 27;
public static final int COMMAND_PROPERTY_CHANGED = 28;
public static final int COMMAND_DISCARD_WORLD = 29;
public static final int COMMAND_SET_SPEED = 30;
public static final int COMMAND_WORLD_FOCUS_GAINED = 40;
public static final int COMMAND_WORLD_FOCUS_LOST = 41;
private static int nextCommandSequence = 1;
public final int commandSequence;
public final int commandType;
public final int[] extraInfo;
| Construct a command of the given type, and with any number of additional parameters.
|
public Command(int commandType, int... extraInfo)
{
this.commandSequence = nextCommandSequence++;
this.commandType = commandType;
this.extraInfo = extraInfo;
}
| Check if an event is a key event.
|
public static boolean isKeyEvent(int event)
{
return event >= KEY_DOWN && event <= KEY_TYPED;
}
| Check if an even is a mouse event.
|
public static boolean isMouseEvent(int event)
{
return event >= MOUSE_CLICKED && event <= MOUSE_EXITED;
}
}
top,
use,
map,
class Command
. Command
. isKeyEvent
. isMouseEvent
102 neLoCode
+ 15 LoComm