Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.cult3d.device
Class MouseDevice

    java.lang.Object
      |
      +--com.cult3d.device.MouseDevice

public class MouseDevice
extends java.lang.Object

This class provides a way to query information about the mouse cursors position relative the Cult3D Player window and the mouse button states.

Since:
  Cult3D 4.2

Field Summary
`static Sprite` | `DEFAULT_CURSOR` The default mouse cursor.
`static int` | `LEFT` Indicates that the left mouse button is pressed.
`static int` | `NONE` Indicates that no mouse button is pressed.
`static int` | `RIGHT` Indicates that the right button is pressed.

Constructor Summary
`MouseDevice()` Constructs an instance of this class.

Method Summary
`java.lang.String` | `getInfo()` This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.
`int` | `getMouseButtonState()` Returns the state of the mouse buttons.
`Node` | `getMouseOverNode()` This method checks what node is under the current mouse position and returns the topmost node it finds.
`java.awt.Point` | `getMousePosition()` Returns the current coordinate of the mouse relative to the Cult3D Player window.
`int` | `getMouseXPosition()` Returns the current x coordinate of the mouse relative to the Cult3D Player window.
`int` | `getMouseYPosition()` Returns the current y coordinate of the mouse relative to the Cult3D Player window.
`void` | `setCursor(Sprite sprite)` Changes the mouse cursor to the the given Sprite object.
`java.lang.String` | `toString()` Returns a string representation of the values of this object. This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### NONE

    public static final int NONE

  Indicates that no mouse button is pressed.
  Since:
    Cult3D 4.2

### RIGHT

    public static final int RIGHT

  Indicates that the right button is pressed.
  Since:
    Cult3D 4.2

### LEFT

    public static final int LEFT

  Indicates that the left mouse button is pressed.
  Since:
    Cult3D 4.2

### DEFAULT_CURSOR

    public static final Sprite DEFAULT_CURSOR

  The default mouse cursor.
  Since:
    Cult3D 4.2

Constructor Detail

### MouseDevice

    public MouseDevice()

  Constructs an instance of this class.
  Since:
    Cult3D 4.2

Method Detail

### setCursor

    public void setCursor(Sprite sprite)

  Changes the mouse cursor to the the given Sprite object.

  To use a custom mouse pointer, first add a new cursor resource in the Cult3D Designer. Then create a new Sprite object by using the static Sprite.getSprite() method and passing it the name of the cursor resource, as defined in the Cult3D Designer. Then pass this Sprite object to this method.

  To change back to the system default cursor, use the static DEFAULT_CURSOR member of this class as argument.

  Parameters:
    `sprite` - Sprite to use as cursor
  Since:
    Cult3D 4.2
  See Also:
    `Sprite`

### getMouseXPosition

    public int getMouseXPosition()

  Returns the current x coordinate of the mouse relative to the Cult3D Player window. The upper left corner of the window has x coordinate = 0.

  The mouse coordinate is only updated when the mouse is hoovering over the Cult3D Player window, so the x coordinate returned when the mouse cursor is outside the window is undefined. Normally the x value remains as it was when the mouse cursor left the window area. The exception is thrown when the mouse is dragged, i.e. moved with the left mouse button down. Then the mouse cursors position will be updated outside the Cult3D Player window as well.

  Returns:
    the current x coordinate of the mouse cursor relative the Cult3D Player window.
  Since:
    Cult3D 4.2

### getMouseYPosition

    public int getMouseYPosition()

  Returns the current y coordinate of the mouse relative to the Cult3D Player window. The upper left corner of the window has y coordinate = 0.

  The mouse coordinate is only updated when the mouse is hoovering over the Cult3D Player window, so the x coordinate returned when the mouse cursor is outside the window is undefined. Normally the x value remains as it was when the mouse cursor left the window area. The exception is when the mouse is dragged, i.e. moved with the left mouse button down. Then the mouse cursors position will be updated outside the Cult3D Player window as well.

  Returns:
    the current y coordinate of the mouse cursor relative the Cult3D Player window.
  Since:
    Cult3D 4.2

### getMousePosition

    public java.awt.Point getMousePosition()

  Returns the current coordinate of the mouse relative to the Cult3D Player window. The upper left corner of the window has the coordinate (0,0).

  The mouse coordinate is only updated when the mouse is hoovering over the Cult3D Player window, so the coordinate returned when the mouse cursor is outside the window is undefined. Normally the coordinate remains as it was when the mouse cursor left the window area. The exception is when the mouse is dragged, i.e. moved with the left mouse button down. Then the mouse cursors position will be updated outside the Cult3D Player window as well.

  Returns:
    A java.awt.Point that contains the x and y coordinate of the mouse cursor.
  Since:
    Cult3D 4.2

### getMouseButtonState

    public int getMouseButtonState()

  Returns the state of the mouse buttons. The valid states are defined by the three static variables LEFT, RIGHT, and NONE, and indicates that the left, right, or none of the mouse buttons are pressed respectively.
  Returns:
    The current mouse button state.
  Since:
    Cult3D 4.2

### getMouseOverNode

    public Node getMouseOverNode()

  This method checks what node is under the current mouse position and returns the topmost node it finds.
  Returns:
    The topmost node beneath the mouse cursor
  Since:
    Cult3D 5.3
  See Also:
    `CultWindow.getNodeAtCoordinate(int x, int y)`

### getInfo

    public java.lang.String getInfo()

  This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.

  Returns:
    A string representing this object.
  Since:
    Cult3D 5.3

### toString

    public java.lang.String toString()

  Returns a string representation of the values of this object.

  This method is intended to be used only for debugging purposes, and the content and format of the returned string may vary between implementations and versions of Cult3D.

  Overrides:
    toString in class java.lang.Object
  Returns:
    A string representing this object.

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD