Skip to content

Latest commit

 

History

History
73 lines (52 loc) · 1.75 KB

README.md

File metadata and controls

73 lines (52 loc) · 1.75 KB

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.