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

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

问题描述

我想摆脱基于列表的组件中典型的Flex翻转颜色,并显示自己的翻滚渲染样式。



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



它可以很难吗?有没有办法将翻转颜色设置为透明?有没有其他的方法让我的渲染器找出是否突出显示一个项目?

谢谢!

编辑:当然,我可以将rollOver颜色设置为white,并将alternatingRowColors设置为类似于白色的颜色。作弊类型:)

解决方案

@invertedSpear,谢谢你的提示。



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

pre code > override保护函数drawHighlightIndicator(指标:Sprite,x:Number,y:Number,width:Number,
height:Number,color:uint,itemRenderer:IListItemRenderer):void
{
/ /获得风格 - 这是正确的地方?
var alpha:Number = this.getStyle(rollOverAlpha);
if(isNaN(alpha))
alpha = 1.0;

//不需要绘制如果alpha 0
if(alpha< = 0)
return;

//绘制 - 这是从超类复制的,alpha参数添加到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;





$ b现在如果你为类添加一个样式声明, :
$ b

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



<在SDK中改变它当然是一个更好的选择,因为你只需要触摸两个类:ListBase和AdvancedListBase。我会检查一个Adobe Jira问题。


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.

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?

Thanks!

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

解决方案

@invertedSpear, thanks for your hint.

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
{
    ...
}

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天全站免登陆