2
votes

Is there a way to set the priority (CursorManagerPriority.HIGH) of a mouse cursor set via Mouse.cursor = '...';?

Long story short, I've had to resort to using the CursorManager to apply cursors, because setting the priority is crucial for my application due to the HTML control overriding all cursor changes without a high priority. Setting cursors with the cursor manager totally works, but the cursors aren't as fast/response as those rendered at the OS level (as described here).

If there isn't a way, my next question is: is there any way to suppress the cursor changes made by the HTML control? Setting mouseEnabled = false does it... but disables all mouse events on the HTML page, so that doesn't work.


Example:

This doesn't work:

setInterval(function():void { Mouse.cursor = 'ibeam'; }, 100);

Setting a cursor with a high priority works, however:

// ibeamCursor is an embedded PNG
CursorManager.setCursor(ibeamCursor, CursorManagerPriority.HIGH, -2, -4);

(this code is used at mx:Application scope)

2

2 Answers

0
votes

I'm going to assume that you have access to the code for the HTML control...otherwise, I'm not sure you can do this at all.

I don't think you can set priority on cursors set by Mouse.cursor = "..."; (tho I could be wrong...if anyone has info to the contrary, feel free to correct me.)

However, I think you can very easily suppress cursor changes simply by using a boolean variable and an if-statement.

var customCursors:Boolean;

Then, on each place where the cursor changes occur...

if(customCursors == true)
{
    Mouse.cursor = "mycursor";
}

This will allow or suppress changes to the cursors, simply by changing the customCursors variable.

However, there may be something more useful if you're dealing with two conflicting cursors, and you want one to only take place during certain instances. For that, you could try a different if statement.

In my own code, I want one cursor to show up only while dragging an object, but not just while the mouse is over it. One is inside the move event, and the other inside the over event. There was a third that would show up only when the object was dragged over a certain point, and when it was not, it needed to be the regular dragging cursor.

This created a rather annoying conflict...

To fix that, I actually checked the Mouse.cursor property in my if statement! The placement of various Mouse.cursor statements in my events created a sort of priority for the cursors. It works perfectly.

In my mouse over statement:

Mouse.cursor = "hand";

In my mouse down statement (where I start dragging):

Mouse.cursor = "dragging";

In my move statement:

if(Mouse.cursor == "draggingover")
{
    Mouse.cursor = "dragging";
}

In my mouse up statement (where I stop dragging):

Mouse.cursor = "hand";

In my mouse out statement:

Mouse.cursor = "pointer";

I hope this helps! If it does, don't worry about overlooking this seemingly obvious solution...I think we're all prone to do so when we're looking for built-in functions.

If this isn't helpful, sorry. Again, I don't think there is another way, but if anyone knows of one, please weigh in.

0
votes

I believe HTML control inherits from ScrollControlBase. Try fixing your Mouse issues on that parent control, rather than on the HTML control.

Also, you can try overriding the HTML control, adding code to remove default cursor look and feel. See this blog post, and just do the opposite.