Respond to a user clicking the screen
- 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
- net.rim.device.api.ui.component.Dialog
- 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 {
- In your implementation of the touchEvent(TouchEvent message) method, invoke TouchEvent.getEvent().
- Check if the value that TouchEvent.getEvent()
returns is equal to TouchEvent.CLICK.
protected boolean touchEvent(TouchEvent message) {
switch(message.getEvent()) {
case TouchEvent.CLICK:
Dialog.alert("CLICK occurred");
return true;
}
return false;
}
Was this information helpful? Send us your comments.