Respond to a scroll action
1.
Import the following classes:
•
net.rim.device.api.ui.TouchEvent
•
net.rim.device.api.ui.TouchGesture
•
net.rim.device.api.ui.Field
•
net.rim.device.api.ui.Manager
•
net.rim.device.api.ui.Screen
•
net.rim.device.api.system.Display
•
net.rim.device.api.ui.component.Dialog
•
net.rim.device.api.ui.Screen
2.
Create a class that extends the
Manager
class.
public class newManager extends Manager {
3.
In your implementation of the
touchEvent(TouchEvent message)
method, check if the value
TouchEvent.getEvent()
returns is equal to
TouchEvent.MOVE
.
protected boolean touchEvent(TouchEvent message) {
switch(message.getEvent()) {
case TouchEvent.MOVE:
return true;
}
return false;
}
Respond to a user touching the screen in two locations at the same time
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, check if the following method
invocations return values greater than zero:
TouchEvent.getX(1)
,
TouchEvent.getY(1)
,
TouchEvent.getX(2)
,
TouchEvent.getY(2)
.
protected boolean touchEvent(TouchEvent message) {
switch(message.getEvent()) {
case TouchEvent.MOVE:
if(message.getX(1) > 0 && message.getY(1) > 0) {
Development Guide
Touch screen events
39