Disable overflow color for List or DataGrid components

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

Using useRollOver in 'false' is not an option , since disabling it will also cause the List.isItemHighlighted () function to always return false. My custom renderer relies on this feature.

Is it really that hard? Can't set the transparent flip color? Is there any other way for my renderer to find out if an element is selected?

Thanks!

EDIT: Of course, I could set the rollOver color to β€œwhite” and set alternatingRowColors to something similar to white. Type of cheating :)

+4
source share
3 answers

@invertedSpear, thanks for your hint.

It really works! I mean, subclasses, not SDK editing, have not tried this. But you can subclass for 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 go:

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

Changing this in the SDK would, of course, be the best choice, since you would only need to touch on two classes: ListBase and AdvancedListBase. I will check for a problem with Adobe Jira.

+2
source

By setting the autoDrawBackground property to 'false' in the custom ItemRenderer, you can turn off the default and selected background colors, and then set them to your renderer if necessary.

This is just a spark list option. MX controls do not have.

+3
source

There is a way to do this, but it is not fun. You can edit the SDK itself (Yay for open source). You can go in there, find where it sets the highlight color, and start adding code to create a public property for the selected alpha. At first I backed up your SDK, as there is an opportunity to completely veil the situation.

It looks like the rollOver code is in the ListBase class, so I would make a copy or extension of this class and add the code for roll over alpha. Then I will make a copy of the List class, which inherits from this new ListBase.

Good luck to my friend, and if you are successful, share your new classes with the world, as I am sure that others may want to do the same.

0
source

Source: https://habr.com/ru/post/1302219/


All Articles