Package | ardisia.managers.cursorManager |
Class | public class CursorManager |
Inheritance | CursorManager Object |
To use a custom cursor, the cursor must be first registered via the registerCursor() method. After registration, use the cursor via setCursor(). The exception to this rule is that all of the cursors in the DefaultCursors class are always available.
This class is completely static so there is no need to initialize it before use.
If a user opens a ContextMenu via a right click, this manager will revalidate the cursor to keep any possible custom cursors displayed. However, when a native (OS managed) context menu is opened, very strange unpredictable mouse events are dispatched and custom mouse behaviour isn't reliable. Thus, it is highly recommended that users either route all right clicks to an Ardisia FlexContextMenu or disable the OS context menu altogether by adding a global right_click mouse listener. See the online docs for more information.
View the technical documentation on the Ardisia Labs website for more information.
Property | Defined By | ||
---|---|---|---|
availableCursors : Vector.<CursorData> [static]
The vector of CursorData objects that are available because they
have been registered. | CursorManager | ||
colorMode : String = auto [static]
The default color mode to use for the default cursors that have both a
black and white version. | CursorManager | ||
currentCursor : CursorData [static]
Returns the CursorData object for the currently displayed cursor. | CursorManager | ||
currentPriority : Number [static]
Returns the priority of the currently displayed cursor. | CursorManager | ||
cursorList : Vector.<CursorListData> [static]
The array of cursors to be displayed on the screen, as set by
setCursor() calls. | CursorManager |
Method | Defined By | ||
---|---|---|---|
registerCursor(name:String, hotSpot:Point, assets:Array, frameRate:uint):void [static]
Register a cursor for use. | CursorManager | ||
removeAllCursors():void [static]
Removes all set cursors from the cursorList. | CursorManager | ||
removeCursor(name:String, priority:uint, removeAll:Boolean = false):void [static]
Remove the most recent cursor matching the provided name and priority. | CursorManager | ||
removeGroup(group:String):void [static]
Remove all the cursors with the specified group token. | CursorManager | ||
setCursor(name:String, priority:uint = 1, group:String = null, forceNonNative:Boolean = false, systemManager:ISystemManager = null):void [static]
Sets a cursor by name, priority, and (optionally) group token. | CursorManager | ||
unregisterAllCursors():void [static]
Remove all registered cursors. | CursorManager | ||
unRegisterCursor(name:String):void [static]
Remove a registered cursor. | CursorManager | ||
validateCursor():void [static]
Calls to this method will use the cursorList to determine the cursor
that should be displayed. | CursorManager |
Method | Defined By | ||
---|---|---|---|
addContextHandlers(sm:ISystemManager):void [static]
Add listeners for the context menu. | CursorManager | ||
animationHandler(event:TimerEvent):void [static]
Handles the timer event used to animate the fake cursor. | CursorManager | ||
busyHandler(event:MouseEvent):void [static]
Handles mouse events when the busy cursor is active. | CursorManager | ||
contextMenuHandler(event:Event):void [static]
Handles events on the context menu. | CursorManager | ||
getColor():String [static]
Return the cursor color theme to use (black/white). | CursorManager | ||
getCursorData(name:String):CursorData [static]
Returns the CursorData object in the availableCursors array. | CursorManager | ||
initializeCursor(cursor:CursorData):void [static]
Register the cursor with the player's native mouse cursor support. | CursorManager | ||
mouseHandler(event:MouseEvent):void [static]
Handles mouse events for the fake cursor. | CursorManager | ||
removeBusyHandlers(sysManager:ISystemManager):void [static]
Remove the mouse event listeners for the busy cursor. | CursorManager | ||
removeContextHandlers():void [static]
Remove listeners for the context menu. | CursorManager | ||
removeFakeCursor():void [static]
Remove the fake cursor and all associated listeners. | CursorManager |
availableCursors | property |
public static var availableCursors:Vector.<CursorData>
The vector of CursorData objects that are available because they have been registered.
Cursors listed in the DefaultCursors class are only added here once they are displayed via setCursor(), but they always available. DefaultCursors cursors are only added here when they are set to save memory.
The default value is Vector.
.
colorMode | property |
public static var colorMode:String = auto
The default color mode to use for the default cursors that have both a black and white version.
If the mode is "auto", the color will be set to white if the OS flash is running inside of is detected as Windows and black is the OS is OS X.
Only applies to default cursors not yet registered. To re-register a default cursor with a new color, unregister the cursor first.
The default value is "auto"
.
currentCursor | property |
public static var currentCursor:CursorData
Returns the CursorData object for the currently displayed cursor.
The default value is null
.
currentPriority | property |
public static var currentPriority:Number
Returns the priority of the currently displayed cursor.
The default value is NaN
.
cursorList | property |
public static var cursorList:Vector.<CursorListData>
The array of cursors to be displayed on the screen, as set by setCursor() calls. Each element in the array is a CursorListData object.
Sorted by priority. Iterate over the vector to check each cursor.
Can also include flash.ui.MouseCursors or any cursor from the DefaultCursors class.
The default value is Vector.
.
addContextHandlers | () | method |
protected static function addContextHandlers(sm:ISystemManager):void
Add listeners for the context menu.
Parameters
sm:ISystemManager — the SystemManager
|
animationHandler | () | method |
protected static function animationHandler(event:TimerEvent):void
Handles the timer event used to animate the fake cursor.
Parameters
event:TimerEvent — the TimerEvent that triggered the handler
|
busyHandler | () | method |
protected static function busyHandler(event:MouseEvent):void
Handles mouse events when the busy cursor is active.
Parameters
event:MouseEvent — the MouseEvent that triggered the handler
|
contextMenuHandler | () | method |
protected static function contextMenuHandler(event:Event):void
Handles events on the context menu.
Parameters
event:Event — the Event that triggered the handler
|
getColor | () | method |
protected static function getColor():String
Return the cursor color theme to use (black/white). If colorMode is "auto", the color will be automatically determined based on the OS.
ReturnsString — String "white"
|
getCursorData | () | method |
protected static function getCursorData(name:String):CursorData
Returns the CursorData object in the availableCursors array.
Parameters
name:String — the name of the CursorData object to search for
|
CursorData — CursorData object
|
initializeCursor | () | method |
protected static function initializeCursor(cursor:CursorData):void
Register the cursor with the player's native mouse cursor support. Generally, should not be called outside of this class.
Parameters
cursor:CursorData |
mouseHandler | () | method |
protected static function mouseHandler(event:MouseEvent):void
Handles mouse events for the fake cursor.
Parameters
event:MouseEvent — the MouseEvent that triggered the handler
|
registerCursor | () | method |
public static function registerCursor(name:String, hotSpot:Point, assets:Array, frameRate:uint):void
Register a cursor for use. Cursor names are unique. If a cursor has a name that is already registered, the new cursor will not be registered.
No need to register OS cursors in the flash.ui.MouseCursors class. They are always available. This is true for any cursor found in the DefaultCursors class.
Parameters
name:String — the name of the cursor used in setCursor()
| |
hotSpot:Point — the Point relative to the upper-left origin that defines
the cursor's hot region
| |
assets:Array — an array of the embedded assets used to define the cursor.
A typical cursor uses a single asset. However, animated cursors use
multiple classes.
| |
frameRate:uint — a uint of the framerate to animate the assets. Only
relevant if the assets parameter's length is greater than one.
|
removeAllCursors | () | method |
public static function removeAllCursors():void
Removes all set cursors from the cursorList. Does not affect the registered cursors.
removeBusyHandlers | () | method |
protected static function removeBusyHandlers(sysManager:ISystemManager):void
Remove the mouse event listeners for the busy cursor.
Parameters
sysManager:ISystemManager — systemManager to remove the listeners from
|
removeContextHandlers | () | method |
protected static function removeContextHandlers():void
Remove listeners for the context menu.
removeCursor | () | method |
public static function removeCursor(name:String, priority:uint, removeAll:Boolean = false):void
Remove the most recent cursor matching the provided name and priority. If multiple cursors with the passed name and priority are set, repeated calls to this method would be necessary to remove them all, unless the third parameter "removeAll" is set to "true".
See the removeGroup() method for an alternative method of removing cursors.
Parameters
name:String — the name of the cursor to remove
| |
priority:uint — the uint priority of the cursor to remove
| |
removeAll:Boolean (default = false ) — remove all cursors matching the name and priority
|
removeFakeCursor | () | method |
protected static function removeFakeCursor():void
Remove the fake cursor and all associated listeners. No need to remove from systemManager.
removeGroup | () | method |
public static function removeGroup(group:String):void
Remove all the cursors with the specified group token. Does not affect the registered cursors. Applies to all cursors within the group regardless of priority.
Parameters
group:String — the token String
|
setCursor | () | method |
public static function setCursor(name:String, priority:uint = 1, group:String = null, forceNonNative:Boolean = false, systemManager:ISystemManager = null):void
Sets a cursor by name, priority, and (optionally) group token.
Note, setting cursor via this method will not necessarily change the cursor. The cursor displayed is determined by set cursors' priorities with ties going to most recently set cursor.
Parameters
name:String — the name of the cursor to set
| |
priority:uint (default = 1 ) — the uint priority
| |
group:String (default = null ) — an optional string that can serve to group certain cursors
together so they can all be removed as a group
| |
forceNonNative:Boolean (default = false ) — true to display the cursor non-natively even if
native cursors are supported
| |
systemManager:ISystemManager (default = null ) — the SystemManager to attach a contextMenu handler
for a native cursor and the stage to add a fakeCursor if the cursor
is fake
|
unregisterAllCursors | () | method |
public static function unregisterAllCursors():void
Remove all registered cursors.
unRegisterCursor | () | method |
public static function unRegisterCursor(name:String):void
Remove a registered cursor. Note, this method makes the un-registered cursor unavailable to be set until re-registered. To simply stop a cursor from being displayed without unregistering it, see removeCursor().
Parameters
name:String — the name of the Cursor to un-register
|
validateCursor | () | method |
public static function validateCursor():void
Calls to this method will use the cursorList to determine the cursor that should be displayed.
Call this function to reset the cursor if the cursor was lost for any reason or other components have changed the cursor.