Help Center

Local Navigation

Object: MouseEvent

Availability

BlackBerry® Device Software version 4.6 or later

Extends

UIEvent

The MouseEvent object extends the UIEvent object and represents an event generated by the BlackBerry® device trackball or trackwheel. It provides contextual information associated with clicking the trackball or trackwheel and moving the pointer in the BlackBerry® Browser window.

To create an instance of a MouseEvent, you must invoke Document.createEvent() with an input parameter of ”MouseEvent”.

MouseEvent properties

Property name

Type

Description

Status

Availability

altKey

boolean

Returns true if the ALT key is pressed or ALT lock is on.

read only

4.6 or later

button

short

Returns a value indicating which mouse button changed state. Because BlackBerry® devices have a single button (the trackball or trackwheel), this parameter will always return a value of “0”.

read only

4.6 or later

clientX

int

Returns the horizontal coordinate within the BlackBerry Browser window where the event occurred.

read only

4.6 or later

clientY

int

Returns the vertical coordinate within the BlackBerry Browser window where the event occurred.

read only

4.6 or later

ctrlKey

boolean

Returns false. The BlackBerry device does not have a CTRL key.

read only

4.6 or later

metaKey

boolean

Returns false. The BlackBerry device does not have a Meta key.

read only

4.6 or later

relatedTarget

EventTarget

Returns the EventTarget that the pointer is moving over or moving off of.

read only

4.6 or later

screenX

int

Returns the horizontal coordinate on the BlackBerry device screen where the event occurred.

read only

4.6 or later

screenY

int

Returns the vertical coordinate on the BlackBerry device screen where the event occurred.

read only

4.6 or later

shiftKey

boolean

Returns true if the SHIFT key is pressed.

read only

4.6 or later

Mouse event types

Event type

Bubbles

Cancelable

Description

click

yes

yes

Occurs when the user clicks the trackball or trackwheel on a BlackBerry® device, or, on touchscreen devices, when the user performs a tap.

This event type includes the following context information:

UIEvent.detail, MouseEvent.altKey, MouseEvent.button, MouseEvent.clientX, MouseEvent.clientY, MouseEvent.ctrlKey, MouseEvent.metaKey, MouseEvent.screenX, MouseEvent.screenY, MouseEvent.shiftKey

mousedown

yes

yes

Occurs when the user depresses the trackwheel or trackball on a BlackBerry device.

This event type includes the following context information:

UIEvent.detail, MouseEvent.altKey, MouseEvent.button, MouseEvent.clientX, MouseEvent.clientY, MouseEvent.ctrlKey, MouseEvent.metaKey, MouseEvent.screenX, MouseEvent.screenY, MouseEvent.shiftKey

mousemove

yes

no

Occurs when the user moves the pointer while it is over an element.

This event type includes the following context information:

MouseEvent.altKey, MouseEvent.clientX, MouseEvent.clientY, MouseEvent.ctrlKey, MouseEvent.metaKey, MouseEvent.screenX, MouseEvent.screenY, MouseEvent.shiftKey

mouseout

yes

yes

Occurs when the user moves the pointer off of an element.

This event type includes the following context information:

MouseEvent.altKey, MouseEvent.clientX, MouseEvent.clientY, MouseEvent.ctrlKey, MouseEvent.metaKey, MouseEvent.relatedTarget (indicating which EventTarget the pointer is leaving), MouseEvent.screenX, MouseEvent.screenY, MouseEvent.shiftKey

mouseover

yes

yes

Occurs when the user moves the pointer over an element.

This event type includes the following context information:

MouseEvent.altKey, MouseEvent.clientX, MouseEvent.clientY, MouseEvent.ctrlKey, MouseEvent.metaKey, MouseEvent.relatedTarget (indicating which EventTarget the pointer is entering), MouseEvent.screenX, MouseEvent.screenY, MouseEvent.shiftKey

mouseup

yes

yes

Occurs when the user releases the trackwheel or trackball on a BlackBerry device.

This event type includes the following context information:

UIEvent.detail, MouseEvent.altKey, MouseEvent.button, MouseEvent.clientX, MouseEvent.clientY, MouseEvent.ctrlKey, MouseEvent.metaKey, MouseEvent.screenX, MouseEvent.screenY, MouseEvent.shiftKey

MouseEvent methods

Method name

Description

Availability

initMouseEvent()

Initializes the value of a MouseEvent.

4.6 or later

Method: MouseEvent.initMouseEvent()

Availability

BlackBerry® Device Software version 4.6 or later

The initMouseEvent() method initializes the value of a MouseEvent created by Document.createEvent(). This method can only be called before the MouseEvent has been dispatched.

Syntax

MouseEvent.initMouseEvent( typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, screenXArg, screenYArg, clientXArg, clientYArg, ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, buttonArg, relatedTargetArg )

Parameters

Parameter

Type

Description

typeArg

String

Specifies the MouseEvent type. This parameter may have one of the following values:

canBubbleArg

boolean

When true, this parameter indicates that the event can bubble upwards through the DOM tree. This parameter sets the value of Event.bubbles.

cancelableArg

boolean

When true, this parameter indicates that the event’s default action can be cancelled. This parameter sets the value of Event.cancelable.

viewArg

AbstractView

Specifies the window or frame that is generating the event. This parameter sets the value of UIEvent.view.

detailArg

long

Specifies the number of clicks associated with the event. This parameter sets the value of UIEvent.detail.

screenXArg

long

Specifies the horizontal coordinate on the BlackBerry® device screen where the event occurred.

screenYArg

long

Specifies the vertical coordinate on the BlackBerry device screen where the event occurred.

clientXArg

long

Specifies the horizontal coordinate within the BlackBerry® Browser window where the event occurred.

clientYArg

long

Specifies the vertical coordinate within the BlackBerry Browser window where the event occurred.

ctrlKeyArg

boolean

Specifies whether the CTRL key was pressed during the event.

altKeyArg

boolean

Specifies whether the ALT key was pressed during the event.

shiftKeyArg

boolean

Specifies whether the SHIFT key was pressed during the event.

metaKeyArg

boolean

Specifies whether the meta key was pressed during the event.

buttonArg

unsigned short

Specifies which button was clicked.

relatedTargetArg

EventTarget

Specifies the event’s related EventTarget. A value for this parameter is only necessary if typeArg has a value of “mouseover” or “mouseout”. Otherwise, this parameter should have a value of null.

Return values

None.

Exceptions

None.


Was this information helpful? Send us your comments.