(Tree)Lister SetRowOverlay not sticking

TD 2022.35320

Moving the code to onSetRowLook works, but is not documented !

I am trying to apply custom backgrounds to a treelister based on some operators.
Reading the docs I found the SetRowOverlay command which, per docs, should be called from either an reactionCallback or from onRefresh.
This is the code I came up with (not the biggest fan of using Dicts here, but thats another story :slight_smile: )

def onRefresh(info):
    for row in info["ownerComp"].Data:
        if row["rowObject"] is None: continue
        operatorObject = op( row["rowObject"]["path"])
        try:
            info["ownerComp"].SetRowOverlay(row["sourceIndex"], [*operatorObject.color, 0.5], apply=True)
        except AttributeError:

            continue

The problem here is that the colors are either not working at or not sticking.
Depending on which part of the Treelister I expand or not I sometimes get the flashing colors for maybe a frame.
Also also (hence the AttributeError Catching) Sometimes I do get an error that “None does not have attribute bgColor”, while still having a valid Row-Object.

I assume onRefresh might not be the best place for this?

Putting onRefresh in a delayedCall sometimes results in it working but also not always.


def onRefresh(info):
    run( "args[0]()", lambda : _onRefresh(info), delayFrames = 1 )

grafik

1 Like

You found the correct solution, my friend. I’ll add a note to the wiki and will check into what is happening here at some point.

why do you say onSetRowLook is not documented? Or do you just mean that this usage of it is not specifically documented?

The fact that you have to use onSetRowLook was not documented until just now, instead the docs pointed to onRefresh, which did not work.
But you updated the docs so I suppose this is fixed :slight_smile:

Yeah wiki was vague about it previously. onRefresh should work… I don’t have time to look right this second, but I will