Skip to content

Adobe AIR Native Extension that provides information about native mouse position and events

License

Notifications You must be signed in to change notification settings

airext/native-mouse

Repository files navigation

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.

About

Adobe AIR Native Extension that provides information about native mouse position and events

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published