org.zkoss.zk.ui.event
Class MouseEvent

java.lang.Object
  extended by org.zkoss.zk.ui.event.Event
      extended by org.zkoss.zk.ui.event.MouseEvent
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
CellClickEvent, DropEvent

public class MouseEvent
extends Event

Represents an event cause by mouse activity.

There are two possible way to identify a mouse event. One is by coordinate (getX() and getY(). The other is by a logical name, called area (getArea()).

Author:
tomyeh
See Also:
Serialized Form

Field Summary
static int ALT_KEY
          Indicates whether the Alt key is pressed.
static int CTRL_KEY
          Indicates whether the Ctrl key is pressed.
static int LEFT_CLICK
          Indicates whether the left button is clicked.
static int MIDDLE_CLICK
          Indicates whether the middle button is clicked.
static int RIGHT_CLICK
          Indicates whether the right button is clicked.
static int SHIFT_KEY
          Indicates whether the Shift key is pressed.
 
Constructor Summary
MouseEvent(java.lang.String name, Component target)
          Construct a mouse relevant event with coordinate or area.
MouseEvent(java.lang.String name, Component target, int x, int y, int pageX, int pageY)
          Constructs a mouse relevant event.
MouseEvent(java.lang.String name, Component target, int x, int y, int pageX, int pageY, int keys)
          Constructs a mouse relevant event.
MouseEvent(java.lang.String name, Component target, java.lang.String area, int keys)
          Constructs a mouse relevant event with a logic name called area.
 
Method Summary
 java.lang.String getArea()
          Returns the logical name of the area that the click occurs, or null if not available.
 Component getAreaComponent()
          Returns the component representing the area that the click occurs, or null if not associated with any component.
 int getKeys()
          Returns what keys were pressed when the mouse is clicked, or 0 if none of them was pressed.
static MouseEvent getMouseEvent(AuRequest request)
          Converts an AU request to a mouse event.
 int getPageX()
          Returns the horizontal coordinate of the mouse pointer relative to the whole document.
 int getPageY()
          Returns the vertical coordinate of the mouse pointer relative to the whole document.
 int getX()
          Returns the horizontal coordinate of the mouse pointer relevant to the component.
 int getY()
          Returns the vertical coordinate of the mouse pointer relevant to the component.
 
Methods inherited from class org.zkoss.zk.ui.event.Event
getData, getEvent, getName, getPage, getTarget, isPropagatable, stopPropagation, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ALT_KEY

public static final int ALT_KEY
Indicates whether the Alt key is pressed. It might be returned as part of getKeys().

See Also:
Constant Field Values

CTRL_KEY

public static final int CTRL_KEY
Indicates whether the Ctrl key is pressed. It might be returned as part of getKeys().

See Also:
Constant Field Values

SHIFT_KEY

public static final int SHIFT_KEY
Indicates whether the Shift key is pressed. It might be returned as part of getKeys().

See Also:
Constant Field Values

LEFT_CLICK

public static final int LEFT_CLICK
Indicates whether the left button is clicked.

See Also:
Constant Field Values

RIGHT_CLICK

public static final int RIGHT_CLICK
Indicates whether the right button is clicked.

See Also:
Constant Field Values

MIDDLE_CLICK

public static final int MIDDLE_CLICK
Indicates whether the middle button is clicked.

Since:
5.0.0
See Also:
Constant Field Values
Constructor Detail

MouseEvent

public MouseEvent(java.lang.String name,
                  Component target)
Construct a mouse relevant event with coordinate or area.


MouseEvent

public MouseEvent(java.lang.String name,
                  Component target,
                  int x,
                  int y,
                  int pageX,
                  int pageY)
Constructs a mouse relevant event.

Since:
5.0.0

MouseEvent

public MouseEvent(java.lang.String name,
                  Component target,
                  int x,
                  int y,
                  int pageX,
                  int pageY,
                  int keys)
Constructs a mouse relevant event.

Parameters:
keys - a combination of CTRL_KEY, SHIFT_KEY ALT_KEY, LEFT_CLICK and RIGHT_CLICK.
Since:
5.0.0

MouseEvent

public MouseEvent(java.lang.String name,
                  Component target,
                  java.lang.String area,
                  int keys)
Constructs a mouse relevant event with a logic name called area.

Since:
5.0.0
Method Detail

getMouseEvent

public static MouseEvent getMouseEvent(AuRequest request)
Converts an AU request to a mouse event.

Since:
5.0.0

getArea

public java.lang.String getArea()
Returns the logical name of the area that the click occurs, or null if not available.

It is used only with some special components, that partition itself into several logical areas.

For example, imagemap and chart partition an image into multiple sections represented with the area component (Area).

If each partition is represented with Area, the return value is AbstractComponent.getId(), if it is assigned, or AbstractComponent.getUuid() if not assigned. To simplify the access, you can retrieve it back with getAreaComponent().

See Also:
getAreaComponent()

getAreaComponent

public Component getAreaComponent()
Returns the component representing the area that the click occurs, or null if not associated with any component.

This method assumes getArea() is either a component's ID or a component's UUID. It is true when Area is used to partition a component, such as Imagemap and Chart.

Since:
5.0.4

getX

public final int getX()
Returns the horizontal coordinate of the mouse pointer relevant to the component.


getY

public final int getY()
Returns the vertical coordinate of the mouse pointer relevant to the component.


getPageX

public final int getPageX()
Returns the horizontal coordinate of the mouse pointer relative to the whole document.

Since:
5.0.0

getPageY

public final int getPageY()
Returns the vertical coordinate of the mouse pointer relative to the whole document.

Since:
5.0.0

getKeys

public final int getKeys()
Returns what keys were pressed when the mouse is clicked, or 0 if none of them was pressed. It is a combination of CTRL_KEY, SHIFT_KEY ALT_KEY, LEFT_CLICK and RIGHT_CLICK.



Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo