uk.co.caprica.vlcj.runtime.windows
Class WindowsMouseHook
java.lang.Object
uk.co.caprica.vlcj.runtime.windows.WindowsMouseHook
- All Implemented Interfaces:
- com.sun.jna.AltCallingConvention, com.sun.jna.Callback, com.sun.jna.platform.win32.WinUser.HOOKPROC, com.sun.jna.win32.StdCall, com.sun.jna.win32.StdCallLibrary.StdCallCallback, LowLevelMouseProc
public class WindowsMouseHook
- extends java.lang.Object
- implements LowLevelMouseProc
Windows Mouse Hook implementation.
This implementation registers a Windows hook and translates the native mouse
messages into Java mouse/mouse-motion events.
Not all events are supported, the events that are supported are:
- Mouse Moved
- Mouse Pressed
- Mouse Released
- Mouse Wheel Moved
- Mouse Entered
- Mouse Exited
Any listeners added must execute and return quickly since they will be
executing as part of the native event queue.
There are several deficiencies that could be addressed:
- Modifiers are not passed along with the event
- The semantic events like DRAGGED and CLICKED are not implemented
- Perhaps the events should be notified asynchronously via an executor so as not to hold up the hook
- The thread-safetiness issues are unclear especially wrt creating the hook in the thread
The hook must be started after it has been created.
This class is experimental, unsupported and unstable in operation.
Nested classes/interfaces inherited from interface com.sun.jna.Callback |
com.sun.jna.Callback.UncaughtExceptionHandler |
Fields inherited from interface com.sun.jna.Callback |
FORBIDDEN_NAMES, METHOD_NAME |
Constructor Summary |
WindowsMouseHook(java.awt.Component relativeTo)
Create a new mouse hook. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WindowsMouseHook
public WindowsMouseHook(java.awt.Component relativeTo)
- Create a new mouse hook.
- Parameters:
relativeTo
- component to report mouse coordinates relative to
addMouseListener
public void addMouseListener(java.awt.event.MouseListener listener)
- Parameters:
listener
-
removeMouseListener
public void removeMouseListener(java.awt.event.MouseListener listener)
- Parameters:
listener
-
addMouseMotionListener
public void addMouseMotionListener(java.awt.event.MouseMotionListener listener)
- Parameters:
listener
-
removeMouseMotionListener
public void removeMouseMotionListener(java.awt.event.MouseMotionListener listener)
- Parameters:
listener
-
addMouseWheelListener
public void addMouseWheelListener(java.awt.event.MouseWheelListener listener)
- Parameters:
listener
-
removeMouseWheelListener
public void removeMouseWheelListener(java.awt.event.MouseWheelListener listener)
- Parameters:
listener
-
start
public void start()
- Start the hook.
release
public void release()
callback
public com.sun.jna.platform.win32.WinDef.LRESULT callback(int nCode,
com.sun.jna.platform.win32.WinDef.WPARAM wParam,
MSLLHOOKSTRUCT lParam)
- Specified by:
callback
in interface LowLevelMouseProc
- Returns: