Discipol Discipol - 21 days ago 8
ActionScript Question

How do I refresh the mouse cursor after I remove focus from a TextField?

I want to remove focus and selection on a textfield, if the user types ESC or ENTER, or focuses somewhere else. Thus I do this:

stage.focus = null;

textField.type = TextFieldType.DYNAMIC;
textField.selectable = false;
textField.mouseEnabled = false;


The problem is that, if the mouse is over the editable text field, the mouse is in IBEAM mode (caret cursor) and remains in IBEAM mode, even after the commands above, untill I slightly move the mouse, at which point it returns to the AUTO state.

I want to force the mouse to update itself and satisfy the AUTO state but no matter how much I try to make sure the textfield is disabled, it won't dissapear on its own, only after I move the mouse a bit.

Answer

Simplest answer from your comment:

So I was fidling with your suggestion and for the luls, used Mouse.hide() and then Mouse.show() and it worked. Removed the hide() and it works just with Mouse.show()! Guess it refreshes the mouse cursor. No blink, works perfectly <3

My original answer:

This is sort of a workaround but shouldn't be too difficult to implement. Hopefully someone comes along with a native API solution.

  1. Run your code you posted
  2. Then make cursor invisible
  3. Then place your custom cursor at the mouse position (optional if you don't mind the cursor just disappearing)
  4. On MouseEvent.MOUSE_MOVE remove your custom cursor, and make the cursor visible again.

I doubt you need me to write this code for you, but if you think this method would work for you, and you have a problem implementing this technique, let me know.

If you're worried about different systems having different mouse icons and then suddenly getting your custom one for a split second, the easy solution there is to just always use your custom cursor. You can design it to look exactly as you like; either mimic Windows OS or make it unique.