Can't display colored text in InfoTip with script anymore

In Directory Opus 12, I was able to set up a column using OnAddColumns in a script with color and bold tags, which I could also use in the InfoTip for file types to display colored text. This worked fine and showed the colors as expected. However, in Directory Opus 13.10, the InfoTip now only shows the raw tag text without applying the colors. Am I doing something wrong, or is there another way to apply color formatting in the InfoTip from a script?

1 Like

It should still work. Please show us the details of what you're doing.

I'm putting script in InfoTip, but {scp:Tags line split/RN Tags} doesn't display tags.
Clipboard Image (2)

Script is like this (sorry for messy code):

// Called by Directory Opus to initialize the script
function OnInit(initData)
{
	initData.name = "Tags line split";
	initData.version = "1.2";
	initData.copyright = "(c) 2021 Mano";
	initData.url = "https://example.com";
	initData.desc = "Split tags with new line";
	initData.default_enable = true;
	initData.min_version = "12.0";
}

// Called to add columns to Opus
function OnAddColumns(addColData)
{
	AddColumn(addColData, "RN Tags",     "RN Tags");
}

// Called to get the columns (all at once; multicol = true)
function OnColumns(scriptColData)
{
	var item = scriptColData.item;
	if (item.is_dir) return;
	var meta = item.metadata;
	//DOpus.Output('Sup?')

	for (var e = new Enumerator(scriptColData.columns); !e.atEnd(); e.moveNext())
	{
		var colName = e.item();
		var colData = scriptColData.columns(colName);
		//DOpus.Output(colName)
		if      (colName == "RN Tags")     FillColumn(colData, meta.tags);

	}
}

function AddColumn(addColData, colName, colLabel)
{
	var col = addColData.AddColumn();
	col.name = colName;
	col.method = "OnColumns";
	col.label = colLabel;
	col.justify = "left";
	col.autogroup = true;
	col.multicol = true;
	col.autorefresh = true;
}

function FillColumn(colData, tag)
{	
  var mred = [
          "a:cats",
          "b:dogs"
          ];
  var bld = [  
        "c:birds",
        "d:chickens"];
    var segoe9 = [3,3,5,7,6,10,10,3,4,4,5,8,3,5,3,5,6,6,6,6,6,6,6,6,6,6,3,3,8,8,8,5,11,8,7,8,8,6,6,8,9,3,4,7,6,11,9,9,7,9,7,6,6,8,7,11,7,7,7,4,5,4,8,5,3,6,7,6,7,6,4,7,7,3,3,6,3,11,7,7,7,7,4,5,4,7,6,9,6,6,5,4,3,4,8];    
    var segoe9b = [3,4,6,7,7,10,10,4,4,4,5,8,3,5,3,5,7,7,7,7,7,7,7,7,7,7,3,3,8,8,8,5,11,8,8,7,9,6,6,9,9,4,5,8,6,11,9,9,7,9,8,7,7,9,8,12,8,7,7,4,5,4,8,5,4,6,7,6,7,7,5,7,7,3,3,7,3,11,7,7,7,7,5,5,5,7,7,10,7,6,6,4,4,4,8];
        
    if (!tag) return;
    var newTag = "";
    var nTag = 0;
    for (var g=0;g<tag.count;g++) {
      if (newTag) {
        var zSize = 0;

        if (nTag>300){
          newTag += "\r\n"
          nTag = 0;

         }
        else if (nTag==0)
          zSize = 0
        else if (nTag>144)
          zSize = 300 - nTag
        else zSize =  150 - nTag;
    
        if (zSize<0)
          zSize = 0;
        for (var k = 0;k<Math.floor(zSize / segoe9[0]); k++) {
          newTag += " " ;
          nTag += segoe9[0];
        }        
        if ((zSize- (Math.floor(zSize / segoe9[0])*segoe9[0]) ) == 2) {
          newTag += " ";
          nTag += 2;
        }
      }
      var dTag = "";
      var cTag = tag(g);  
      var bred = false;  
      for (var i=0; i<mred.length;i++)
        if (tag(g)==mred[i]) {
          bred = true;
          break;
        }            
    if(bred)
        dTag += '<#f00000>'+cTag+'</#>'
      else if(('$'+tag(g)).indexOf('$'+'a:')!=-1)
        dTag += '<#000060>'+cTag+'</#>'
      else if(('$'+tag(g)).indexOf('$'+'b:')!=-1)  
        dTag += '<#400000>'+cTag+'</#>'  
      else if(('$'+tag(g)).indexOf('$'+'c:')!=-1)  
        dTag += '<#004000>'+cTag+'</#>'      
      else if(('$'+tag(g)).indexOf('$'+'d:')!=-1)  
        dTag += '<#003000>'+cTag+'</#>'                 
      else 
        dTag += tag(g);
      var b = false;  
      for (var i=0; i<bld.length;i++)
        if (tag(g)==bld[i]) {
          b = true;
          break;
        }  
      if (b)
          dTag = "<b>"+dTag+"</b>";
      for (var j=0;j<cTag.length;j++){
        cCode = cTag.charCodeAt(j)-32;
        if (b)
          var cSize = segoe9b[cCode];
        else
          var cSize = segoe9[cCode];
        if (!cSize)
        //if (cCode<0 || cCode>segoe9.length)
          cSize = 6
        //else cSize = segoe9[cCode];
        nTag += cSize;    
      }
                
       newTag += dTag;
      }
	colData.value = newTag; // Display it as it was.
	colData.sort = newTag; // Sort it with the article removed.
	// TODO: Custom grouping if wanted for certain columns.
}

And it shows like this:
Clipboard Image (5)

This was never actually a supported feature, and some other changes in 13 meant it stopped working. In 13.11.1 we'll introduce an officially supported way for you to do this.

5 Likes

13.11.1 works perfectly.
Thanks :smiley:

1 Like