Adobe AIR Native Extension that provides information about native mouse position and events
Switch branches/tags
Nothing to show
Clone or download
Latest commit ae5274f Oct 30, 2014

README.md

native-mouse License MIT

Windows OSX

The NativeMouse is a simple extension for Adobe AIR for Desktop that provides information about system mouse.

Pure ActionScript Usage

Getting mouse current position through getMouseInfo() method:

if (NativeMouse.isSupported())
{
	var info:Object = new NativeMouse().getMouseInfo();
	
	trace(info.mouseX, info.mouseY);
}

Using NativeMouse asynchronously:

if (NativeMouse.isSupported())
{
	var nativeMouse:INativeMouse = new NativeMouse();

	nativeMouse.addEventListener(NativeMouseEvent.NATIVE_MOUSE_MOVE, nativeMouseHandler);
	nativeMouse.addEventListener(NativeMouseEvent.NATIVE_MOUSE_DOWN, nativeMouseHandler);
	
	nativeMouse.captureMouse();
}

private function nativeMouseHandler(event:NativeMouseEvent):void
{
	this.mousePositionLabel.text = new Point(event.mouseX, event.mouseY);
	
	switch (event.button)
	{
		case NativeMouseButton.LEFT :
			// 
			break;
		
		case NativeMouseButton.RIGHT :
			// 
			break;
			
		case NativeMouseButton.MIDDLE :
			// 
			break;
	}
}

MXML Usage

The NativeMouseTag is designed to be used in MXML code:

<fx:Declarations>
	<tags:NativeMouseTag id="nativeMouse" enabled="true" />
</fx:Declarations>

<s:Label text="{nativeMouse.coordinates}" />

Donating

Support this project an others via Gratipay.

Support via Gratipay

References

Code from DesktopMouse has been used for getMouseInfo() for Windows.