czwartek, 10 czerwca 2010

Flex: Focus issue while chaning cursor with CursorManager

Sometimes when CursorManager is used to swap normal cursor to a custom graphic it won't refresh until mouse pointer is moved to some other element of the application and then moved back.

It happens like that because component gains focus (kind of) on MouseEvent.ROLL_OVER event but making users roll out and over to see a new cursor is not an acceptable solution, unless of course you really don't like those guys, then be my guest and make them suffer.

There are two solutions for this problem:
  • call method UIComponent.setFocus()
    This will work if you don't need focus in any other part of the application, like for an example textfield or on a button
  • componentName.dispatchEvent(new MouseEvent(MouseEvent.ROLL_OVER,true));
    Second solution might not look as sharp as the first one but won't take your focus from other elements and will change cursor the same was as you'd move your mouse out and back from the component you're currently hovering over

Brak komentarzy:

Prześlij komentarz