如何在 Spark 组件上全局消除悬停/翻转效果?

发布于 2024-09-29 10:17:53 字数 528 浏览 8 评论 0 原文

我的目标是从用户界面中删除所有悬停反馈。其动机是测试触摸界面原型,并且不希望用户在鼠标悬停时进行交互队列,而触摸界面则不会有这种情况。

我有一个部分解决方案,但它有两个问题:

  1. 每个组件上都需要一个事件处理程序。
  2. 悬停时闪烁。

     受保护函数 ui_suppressHover(event:MouseEvent):void
        {
            var b = event.currentTarget 作为 UIComponent;
            b.skin.currentState = "向上";
        }
    

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)"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

絕版丫頭 2024-10-06 10:17:54

这是由马克西姆的回答激发的部分解决方案。您可以通过扩展 Button 并重写来创建一个 HoverlessButton 类:

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

您必须首先调用 super impl,因为它是唯一可以正确检查 isDown() 的类,而 isDown() 是私有的。

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:String = 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.

行雁书 2024-10-06 10:17:53

最好重写getCurrentSkinState,例如参见spark Button.as

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

    if (isDown())
        return "down";

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

    return "up";
}

所以只需删除hovered || mouseCaptured“如果”。

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".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文