Package org.apache.pivot.wtk
Class Mouse
- java.lang.Object
-
- org.apache.pivot.wtk.Mouse
-
public final class Mouse extends java.lang.ObjectClass representing the system mouse.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMouse.ButtonEnumeration representing mouse buttons.static classMouse.ScrollTypeEnumeration defining supported scroll types.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcapture(Component capturerComponent)"Captures" the mouse, causing all mouse input to be delegated to the given component rather than propagating down the component hierarchy.static intgetButtonCount()static intgetButtons()static ComponentgetCapturer()Returns the mouse capturer.static CursorgetCursor()static booleanisPressed(Mouse.Button button)Tests the pressed state of a mouse button.static voidrelease()Releases mouse capture, causing mouse input to resume propagation down the component hierarchy.protected static voidsetButtons(int pressedButtons)Set the current bitmask of the buttons that are pressed (only callable from this package).static voidsetCursor(Component component)Sets the cursor based on a given component.static voidsetCursor(Cursor cursor)Sets the cursor to an explicit value.
-
-
-
Method Detail
-
getButtons
public static int getButtons()
- Returns:
- A bitfield representing the mouse buttons that are currently pressed.
-
setButtons
protected static void setButtons(int pressedButtons)
Set the current bitmask of the buttons that are pressed (only callable from this package).- Parameters:
pressedButtons- The current button bitmask.- See Also:
Mouse.Button.getButtons(int)
-
isPressed
public static boolean isPressed(Mouse.Button button)
Tests the pressed state of a mouse button.- Parameters:
button- The button to test.- Returns:
trueif the button is pressed;false, otherwise.
-
getButtonCount
public static int getButtonCount()
- Returns:
- The number of mouse buttons.
-
capture
public static void capture(Component capturerComponent)
"Captures" the mouse, causing all mouse input to be delegated to the given component rather than propagating down the component hierarchy.- Parameters:
capturerComponent- The component that wants to capture the mouse. The mouse pointer must currently be over the component.
-
release
public static void release()
Releases mouse capture, causing mouse input to resume propagation down the component hierarchy.
-
getCapturer
public static Component getCapturer()
Returns the mouse capturer.- Returns:
- The component that has captured the mouse, or
nullif the mouse is not currently captured.
-
getCursor
public static Cursor getCursor()
- Returns:
- The current cursor.
- Throws:
java.lang.IllegalStateException- If the mouse is not currently captured.
-
setCursor
public static void setCursor(Cursor cursor)
Sets the cursor to an explicit value.- Parameters:
cursor- The new mouse cursor value.- Throws:
java.lang.IllegalArgumentException- if the cursor value isnull.java.lang.IllegalStateException- If the mouse is not currently captured.
-
setCursor
public static void setCursor(Component component)
Sets the cursor based on a given component.- Parameters:
component- The component used to set the cursor.- Throws:
java.lang.IllegalArgumentException- if the component isnull, or if the component is not currently visible.
-
-