Name

$eventcmd — Command/object describing a Canvas event.

Synopsis

$eventcmd [cget -optname ] [configure -optname optval ]

Description

The $eventcmd command is used to access information about events received by a Canvas. There is no Hecl command to create event commands - they are passed in as arguments to the -eventhandler specified for an lcdui.canvas.

There are a number of parameters that can be queried:

  • -canvas: Returns the canvas command associated with the event's canvas.

  • -reason: A number representing one of the following reasons:

        public static final int E_NONE = 0;
        public static final int E_PAINT = 1;
        public static final int E_PPRESS = 2;
        public static final int E_PRELEASE = 3;
        public static final int E_PDRAG = 4;
        public static final int E_KPRESS = 5;
        public static final int E_KRELEASE = 6;
        public static final int E_KREPEAT = 7;
        public static final int E_HIDE = 8;
        public static final int E_SHOW = 9;
        public static final int E_RESIZE = 10;
        public static final int E_UNKNOWN = -1;
    	      

    Which correspond to:

    • E_PAINT: Used when the Canvas' paint method is called.

    • E_PRESS: Used when the Canvas' pointerPressed method is called.

    • E_PRELEASE: Used when the Canvas' pointerReleased method is called.

    • E_PDRAG: Used when the Canvas' pointerDragged method is called.

    • E_KPRESS: Used when the Canvas' keyPressed method is called.

    • E_KRELEASE: Used when the Canvas' keyReleased method is called.

    • E_KREPEAT: Used when the Canvas' keyRepeated method is called.

    • E_HIDE: Used when the Canvas' hideNotify method is called.

    • E_SHOW: Used when the Canvas' showNotify method is called.

    • E_RESIZE: Used when the Canvas' sizeChanged method is called.

    • E_UNKNOWN: Used to signify an unknown event.

  • -x: The x coordinate of the event.

  • -y: The y coordinate of the event.

  • -width: The width of the screen area covered by the event.

  • -height: The height of the screen area covered by the event.

  • -keycode: An integer referencing the key involved in the event.

    [Note]Note

    Be aware that different phones may use different numbers.

  • -keyname: Returns a string giving a cross platform name for the key pressed. Names are given here: http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Canvas.html#field_summary, with the addition of "LEFT_SK" and "RIGHT_SK" for the left and right soft keys These only occur when in full screen mode and the soft key events go to the program)

  • -gameaction: Returns the integer code for the game action. Described in further detail here: http://java.sun.com/javame/reference/apis/jsr118/javax/microedition/lcdui/Canvas.html#gameactions

Example

See the example script in the midp20/ directory. http://github.com/davidw/hecl/blob/master/midp20/script.hcl