net.rim.device.api.lcdui
Class BlackBerryCanvas

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Canvas
          extended by net.rim.device.api.lcdui.BlackBerryCanvas
All Implemented Interfaces:
Controllable

public abstract class BlackBerryCanvas
extends Canvas
implements Controllable

This class extends the functionality of the Canvas class to include full touch support and featured text input support.

Classes inheriting from this class can override the BlackBerryCanvas.touchEvent(net.rim.device.api.ui.TouchEvent) method to receive TouchEvent messages.

Applications using this class can call the #setInputHelper method to get the text input support.

The BlackBerryCanvas class implements Controllable and can be queried to retrieve BlackBerry-specific Controls. For instance, on devices which support a virtual keyboard, BlackBerryCanvas.getControl(String) may return a VirtualKeyboardControl object.

See Also:
TouchEvent, Field.touchEvent
Since:
BlackBerry API 4.7.0

Field Summary
 
Fields inherited from class javax.microedition.lcdui.Canvas
DOWN, FIRE, GAME_A, GAME_B, GAME_C, GAME_D, KEY_NUM0, KEY_NUM1, KEY_NUM2, KEY_NUM3, KEY_NUM4, KEY_NUM5, KEY_NUM6, KEY_NUM7, KEY_NUM8, KEY_NUM9, KEY_POUND, KEY_STAR, LEFT, RIGHT, UP
 
Constructor Summary
protected BlackBerryCanvas()
          Creates a new instance of a BlackBerryCanvas.
 
Method Summary
 Control getControl(String controlType)
          Obtain the object that implements the specified Control interface.
 Control[] getControls()
          Obtain the collection of Controls from the object that implements this interface.
 void touchEvent(TouchEvent message)
          Indicates a touch event.
 
Methods inherited from class javax.microedition.lcdui.Canvas
getGameAction, getKeyCode, getKeyName, hasPointerEvents, hasPointerMotionEvents, hasRepeatEvents, hideNotify, isDoubleBuffered, keyPressed, keyReleased, keyRepeated, paint, pointerDragged, pointerPressed, pointerReleased, repaint, repaint, serviceRepaints, setFullScreenMode, showNotify, sizeChanged
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, setTicker, setTitle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 



Constructor Detail

BlackBerryCanvas

protected BlackBerryCanvas()
Creates a new instance of a BlackBerryCanvas.

See Also:
Canvas.Canvas()
Since:
BlackBerry API 4.7.0


Method Detail

touchEvent

public void touchEvent(TouchEvent message)
Indicates a touch event.

Parameters:
message - TouchEvent object containing various input parameters including the event type and touch coordinates.
Since:
BlackBerry API 4.7.0

getControls

public Control[] getControls()
Description copied from interface: Controllable
Obtain the collection of Controls from the object that implements this interface.

Since a single object can implement multiple Control interfaces, it's necessary to check each object against different Control types. For example:

Controllable controllable;
    :
Control cs[];
cs = controllable.getControls();
for (int i = 0; i < cs.length; i++) {
    if (cs[i] instanceof ControlTypeA)
        doSomethingA();
    if (cs[i] instanceof ControlTypeB)
        doSomethingB();
    // etc.
}

The list of Control objects returned will not contain any duplicates. And the list will not change over time.

If no Control is supported, a zero length array is returned.

Specified by:
getControls in interface Controllable
Returns:
the collection of Control objects.
See Also:
Controllable.getControls()
Since:
BlackBerry API 4.7.0

getControl

public Control getControl(String controlType)
Description copied from interface: Controllable
Obtain the object that implements the specified Control interface.

If the specified Control interface is not supported then null is returned.

If the Controllable supports multiple objects that implement the same specified Control interface, only one of them will be returned. To obtain all the Control's of that type, use the getControls method and check the list for the requested type.

Specified by:
getControl in interface Controllable
Parameters:
controlType - the class name of the Control. The class name should be given either as the fully-qualified name of the class; or if the package of the class is not given, the package javax.microedition.media.control is assumed.
Returns:
the object that implements the control, or null.
Throws:
IllegalArgumentException - Thrown if controlType is null.
See Also:
Controllable.getControl(String)
Since:
BlackBerry API 4.7.0





Copyright 1999-2010 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A. All Rights Reserved.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.