views:

18

answers:

2

My goal is to remove all hover feedback from the UI. The motivation is for testing touch interface prototypes and not wanting users to have the queue of interactivity when the mouse hovers which they won't have with a touch interface.

I have a partial solution but it has two problems:

  1. Requires an event handler on each component.
  2. Flickers on hover.

        protected function ui_suppressHover(event:MouseEvent):void
        {
            var b = event.currentTarget as UIComponent;
            b.skin.currentState = "up";
        }
    

    <s:Button x="118" y="60" label="Change em" click="button1_clickHandler(event)" rollOver="button1_rollOverHandler(event)" mouseOver="ui_suppressHover(event)"/>

+2  A: 

It's better to override getCurrentSkinState, e.g. see spark Button.as:

override protected function getCurrentSkinState():String
{
    if (!enabled)
        return "disabled";

    if (isDown())
        return "down";

    if (hovered || mouseCaptured)
        return "over";

    return "up";
}

So just remove hovered || mouseCaptured "if".

Maxim Kachurovskiy
That's helpful, thanks. It doesn't quite work because isDown() is private. I’ll post an alternative as another answer. (I tried putting in this comment but it loses all formatting.)I’m still looking for a solution that disables hover globally instead of having to create custom classes inheriting from each standard component I want to use.
Turadg
A: 

Here's a partial solution spurred by Maxim's answer. You can make a HoverlessButton class by extending Button and overriding as so:

override protected function getCurrentSkinState():String
{               
    var state = super.getCurrentSkinState();
    if (state == "over")
        state = "up";
    return state;
}

You have to call the super impl first because it's the only one that can check properly for isDown(), which is private.

Turadg