public class Pointer extends Buttons
Display
with which it is associated. The associated
MicroUI event type is EVENT_TYPE
.
The pointer can be asked for the absolute position, expressed in terms of the pointer area with which it was
constructed. It can also be asked for scaled co-ordinates (getX()
, getY()
). The scaled area is set
using the setScale(int, int)
method. By default there is no scaling (scaled area is the pointer area).
It is also possible to specify, using setOrigin(int, int)
, an offset to be applied to the co-ordinates
returned by getX()
and getX()
. For example, if the origin is set to be
(20, 30)
then the x position returned will be the absolute x position - 20, and the y position will be
the absolute y position - 30. By default there is no offset.
If both scaling and origin adjustment are specified then the origin offset is first applied to the absolute position
then the scaling is applied.
Modifier and Type | Field and Description |
---|---|
static int |
DRAGGED
Constant for "dragged" action.
|
static int |
EVENT_TYPE
The POINTER event type returned by
getEventType() . |
static int |
MOVED
Constant for "moved" action.
|
Constructor and Description |
---|
Pointer(int width,
int height)
Constructor with a specified area range (
width and height ) that does not support click,
doubleClick nor elapsedTime for any of its buttons. |
Pointer(int nbButtons,
int width,
int height)
Constructor with a specified area range (
width and height ) where elapsedTime, click and
doubleClick features are supported and enabled for the first nbButtons (doubleClick feature is
initialized with a 200ms delay). |
Modifier and Type | Method and Description |
---|---|
int |
getAbsoluteHeight() |
int |
getAbsoluteWidth() |
int |
getAbsoluteX()
Returns the last available absolute x coordinate in pointer area
|
int |
getAbsoluteY()
Returns the last available absolute y coordinate in pointer area
|
int |
getEventType()
Gets the event type associated with the event generator.
|
int |
getHeight() |
int |
getWidth() |
int |
getX()
Returns the last available x coordinate in scaled area (after applying any origin offset and the scale factor).
|
int |
getY()
Returns the last available y coordinate in scaled area (after applying any origin offset and the scale factor).
|
static boolean |
isDragged(int event)
Tells if a pointer event is a drag event.
|
static boolean |
isMoved(int event)
Tells if a pointer event is a move event.
|
void |
move(int x,
int y)
Stores the given position and sends a MicroUI Event to the Pointer's listener.
|
void |
reset(int x,
int y)
Stores the given position.
|
void |
send(int action,
int buttonId)
Sends a MicroUI event for the given action on given button to the listener of the Pointer.
|
void |
setOrigin(int x0,
int y0)
Sets an origin offset.
|
void |
setScale(int areaWidth,
int areaHeight)
Sets a scaled area.
|
buildEvent, clickEnabled, doubleClickEnabled, elapsedTime, enableClick, enableDoubleClick, getAction, getButtonId, isClicked, isDoubleClicked, isLong, isPressed, isReleased, isRepeated, supportsExtendedFeatures
addToSystemPool, get, get, get, getEventHandler, getId, removeFromSystemPool, sendEvent, setEventHandler
public static final int DRAGGED
public static final int EVENT_TYPE
getEventType()
.public static final int MOVED
public Pointer(int width, int height)
width
and height
) that does not support click,
doubleClick nor elapsedTime for any of its buttons. The effect is identical to:new Pointer(0, width, height)
.width
- area widthheight
- area heightpublic Pointer(int nbButtons, int width, int height)
width
and height
) where elapsedTime, click and
doubleClick features are supported and enabled for the first nbButtons
(doubleClick feature is
initialized with a 200ms delay).nbButtons
- the number of buttons that support the extended featureswidth
- area widthheight
- area heightpublic int getAbsoluteHeight()
public int getAbsoluteWidth()
public int getAbsoluteX()
public int getAbsoluteY()
public int getEventType()
EVENT_TYPE
.getEventType
in class Buttons
public int getHeight()
getY()
public int getWidth()
getX()
public int getX()
getAbsoluteX()
public int getY()
getAbsoluteY()
public static boolean isDragged(int event)
event
- the pointer event.public static boolean isMoved(int event)
event
- the pointer event.public void move(int x, int y)
x
- the x coordinatey
- the y coordinatepublic void reset(int x, int y)
x
- the x coordinatey
- the y coordinatepublic void send(int action, int buttonId)
Buttons.CLICKED
and/or Buttons.DOUBLE_CLICKED
events if the matching button's feature is enabled.This method is useful when other input mechanisms wish to simulate button actions.
send
in class Buttons
action
- the button's action: Buttons.PRESSED
, Buttons.RELEASED
, Buttons.LONG
, Buttons.REPEATED
.buttonId
- the button on which the action occurredpublic void setOrigin(int x0, int y0)
x0
- the X coordinate of the new originy0
- the Y coordinate of the new originpublic void setScale(int areaWidth, int areaHeight)
getX()
is scaled so that it returns a value between 0 and
areaWidth-1. The x position returned by getY()
is scaled so that it returns a value between 0 and
areaHeight-1.areaWidth
- the area widthareaHeight
- the area height