Skip to content

Commit

Permalink
FlxMouse: add registerSimpleNativeCursorData()
Browse files Browse the repository at this point in the history
Does the same as setSimpleNativeCursorData(), but doesn't activate the cursor.
Allows fixing #1944 without introducing redundant code.
  • Loading branch information
Gama11 committed Sep 11, 2016
1 parent ed4c344 commit 73b0ff2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
25 changes: 17 additions & 8 deletions flixel/input/mouse/FlxMouse.hx
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class FlxMouse extends FlxPointer implements IFlxInputManager
}

/**
* Shortcut to register a native cursor for in flash
* Shortcut to register a native cursor in flash
*
* @param Name The ID name used for the cursor
* @param CursorData MouseCursorData contains the bitmap, hotspot etc
Expand All @@ -273,32 +273,41 @@ class FlxMouse extends FlxPointer implements IFlxInputManager
}

/**
* Shortcut to create and set a simple MouseCursorData
* Shortcut to register a simple MouseCursorData
*
* @param Name The ID name used for the cursor
* @param CursorData MouseCursorData contains the bitmap, hotspot etc
*/
public function setSimpleNativeCursorData(Name:String, CursorBitmap:BitmapData):MouseCursorData
public function registerSimpleNativeCursorData(Name:String, CursorBitmap:BitmapData):MouseCursorData
{
var cursorVector = new Vector<BitmapData>();
cursorVector[0] = CursorBitmap;

if (CursorBitmap.width > 32 || CursorBitmap.height > 32)
{
throw "BitmapData files used for native cursors cannot exceed 32x32 pixels due to an OS limitation.";
}

var cursorData = new MouseCursorData();
cursorData.hotSpot = new Point(0, 0);
cursorData.data = cursorVector;

registerNativeCursor(Name, cursorData);
setNativeCursor(Name);

Mouse.show();

return cursorData;
}

/**
* Shortcut to create and set a simple MouseCursorData
*
* @param Name The ID name used for the cursor
* @param CursorData MouseCursorData contains the bitmap, hotspot etc
*/
public function setSimpleNativeCursorData(Name:String, CursorBitmap:BitmapData):MouseCursorData
{
var data = registerSimpleNativeCursorData(Name, CursorBitmap);
setNativeCursor(Name);
Mouse.show();
return data;
}
#end

/**
Expand Down
2 changes: 1 addition & 1 deletion flixel/system/debug/interaction/tools/Mover.hx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class GraphicMoverTool extends BitmapData {}
* @author Fernando Bevilacqua ([email protected])
*/
class Mover extends Tool
{
{
private var _dragging:Bool = false;
private var _lastCursorPosition:FlxPoint;

Expand Down

0 comments on commit 73b0ff2

Please sign in to comment.