sdljava.event

Class MouseButtonState

public class MouseButtonState extends Object

The current state of the mouse buttons.

Version: $Id: MouseButtonState.java,v 1.4 2005/01/19 03:09:12 ivan_ganza Exp $

Field Summary
intbuttons
Current button state values (possibly ORed together)
static MapbuttonStateCache
cache of MouseButtonState instances, one for each possible mods values
static intSDL_BUTTON_LEFT
static intSDL_BUTTON_MIDDLE
static intSDL_BUTTON_RIGHT
static intSDL_BUTTON_WHEELDOWN
static intSDL_BUTTON_WHEELUP
Constructor Summary
protected MouseButtonState(int buttons)
Creates a new MouseButtonState instance.
Method Summary
intbutton(int x)
booleanbuttonLeft()
Get if the left mouse button is pressed
booleanbuttonMiddle()
Get if the middle mouse button is pressed
booleanbuttonRight()
Get if the right mouse button is pressed
static MouseButtonStateget(int buttons)
Get the MouseButtonState instance identified by mods.
intgetState()
StringtoString()
Return a string represenation of this object
booleanwheelDown()
Get if the wheel is down
booleanwheelUp()
Get if the wheel is up

Field Detail

buttons

int buttons
Current button state values (possibly ORed together)

buttonStateCache

static Map buttonStateCache
cache of MouseButtonState instances, one for each possible mods values

SDL_BUTTON_LEFT

public static final int SDL_BUTTON_LEFT

SDL_BUTTON_MIDDLE

public static final int SDL_BUTTON_MIDDLE

SDL_BUTTON_RIGHT

public static final int SDL_BUTTON_RIGHT

SDL_BUTTON_WHEELDOWN

public static final int SDL_BUTTON_WHEELDOWN

SDL_BUTTON_WHEELUP

public static final int SDL_BUTTON_WHEELUP

Constructor Detail

MouseButtonState

protected MouseButtonState(int buttons)
Creates a new MouseButtonState instance.

Parameters: buttons an int value

Method Detail

button

final int button(int x)

buttonLeft

public boolean buttonLeft()
Get if the left mouse button is pressed

Returns: if the left mouse button is pressed

buttonMiddle

public boolean buttonMiddle()
Get if the middle mouse button is pressed

Returns: if the middle mouse button is pressed

buttonRight

public boolean buttonRight()
Get if the right mouse button is pressed

Returns: if the middle mouse button is pressed

get

public static MouseButtonState get(int buttons)
Get the MouseButtonState instance identified by mods. This method creates the MouseButtonState instance and caches it if it didn't already exist. Once created we won't need to create new MouseButtonState object instances each time a keyboard event occurs.

Parameters: mods valid button state (possibly OR'd together)

Returns: The singleton MouseButtonState instance

getState

public int getState()

toString

public String toString()
Return a string represenation of this object

Returns: a String represenation of this object

wheelDown

public boolean wheelDown()
Get if the wheel is down

Returns: if the wheel is down

wheelUp

public boolean wheelUp()
Get if the wheel is up

Returns: if the wheel is in the up