Action
Event
Result
In a text field or in Month view in a calendar, this action moves
the empty rectangle cursor in the same direction.
touch the screen in two
locations at the same
time
net.rim.device.api.ui
.TouchEvent.DOWN
net.rim.device.api.ui
.TouchEvent.MOVE
This action highlights the text between the two locations or the
list of items, such as messages, between the two locations. To
add or remove text or items from the selection, users can touch
the screen at another location.
Respond to touch screen events
Respond to system events while the user touches the screen
1.
Import the following classes:
•
net.rim.device.api.ui.TouchEvent
•
net.rim.device.api.ui.Field
•
net.rim.device.api.ui.Manager
•
net.rim.device.api.ui.Screen
2.
Create a class that extends the
Manager
class, the
Screen
class, the
Field
class, or one of the
Field
subclasses.
public class newButtonField extends ButtonField {
3.
In your implementation of the
touchEvent(TouchEvent message)
method, invoke
TouchEvent.getEvent()
.
4.
Check if the value that
TouchEvent.getEvent()
returns is equal to
TouchEvent.CANCEL
.
protected boolean touchEvent(TouchEvent message) {
switch(message.getEvent()) {
case TouchEvent.CANCEL:
Dialog.alert("System event occurred while processing touch events");
return true;
}
return false;
}
Respond to a user sliding a finger up quickly on the screen
1.
Import the following classes:
•
net.rim.device.api.ui.TouchEvent
•
net.rim.device.api.ui.TouchGesture
•
net.rim.device.api.ui.Field
Development Guide
Touch screen events
33