禁用 List 或 DataGrid 组件的翻转颜色 [英] Disable roll-over color for List or DataGrid components

查看:15
本文介绍了禁用 List 或 DataGrid 组件的翻转颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想摆脱基于列表的组件中典型的 Flex 翻转颜色,并显示我自己的翻转渲染风格.

I want to get rid of the typical Flex roll-over color in list-based components, and to display my own style of roll-over rendering.

将 useRollOver 设置为 'false' 不是一个选项,因为禁用它也会使 List.isItemHighlighted() 函数始终返回 false.我的自定义渲染器依赖于该函数.

Setting useRollOver to 'false' is not an option, since disabling that will also make the List.isItemHighlighted() function to always return false. My custom renderer relies on that function.

有那么难吗?有没有办法将翻转颜色设置为透明?我的渲染器是否有其他方法可以确定某个项目是否突出显示?

Can it be so hard? Is there no way of setting that roll-over color to transparent? Is there some other way for my renderer to figure out if an item is highlighted?

谢谢!

当然,我可以将 rollOver 颜色设置为白色",并将alternateRowColors 设置为类似于白色的颜色.有点作弊:)

Of course I could set the rollOver color to 'white' and set the alternatingRowColors to something similar to white. Kind of cheating :)

推荐答案

@invertedSpear,感谢您的提示.

@invertedSpear, thanks for your hint.

它确实有效!我的意思是,子类化,而不是编辑 SDK,还没有尝试过.但是您可以做的是为 List、DataGrid 等(甚至 AdvancedDataGrid)创建一个子类并添加以下函数:

It actually works! I mean, subclassing, not editing the SDK, haven't tried that. But what you can do is to create a subclass for a List, DataGrid etc (or even AdvancedDataGrid) and add the following function:

override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, width:Number,
    height:Number, color:uint, itemRenderer:IListItemRenderer):void
{
    // get style -- is this the right place?
    var alpha:Number = this.getStyle("rollOverAlpha");
    if (isNaN(alpha))
        alpha = 1.0;

    // no need to draw if alpha 0
    if (alpha <= 0)
        return;

    // draw -- this has been copied from superclass, and the alpha parameter added to beginFill()
    var g:Graphics = Sprite(indicator).graphics;
    g.clear();
    g.beginFill(color, alpha);
    g.drawRect(0, 0, width, height);
    g.endFill();

    indicator.x = x;
    indicator.y = y;
}

现在,如果您向类添加样式声明,您就可以开始了:

Now if you add a style declaration to the class, you are ready to roll:

[Style(name="rollOverAlpha", type="Number", inherit="no")]
public class DataGridExt extends DataGrid
{
    ...
}

在 SDK 中更改此设置当然是更好的选择,因为您只需接触两个类:ListBase 和 AdvancedListBase.我会检查一个 Adob​​e Jira 问题..

Changing this in the SDK would of course be a better choice since you would only have to touch two classes: ListBase and AdvancedListBase. I'll check for an Adobe Jira Issue on that..

这篇关于禁用 List 或 DataGrid 组件的翻转颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆