A dynamic subwidget still shows if a label has pre-inputted text

Posts: 81
Not sure if this is a bug or not but here goes:

Say I have a starting grid ticker, and I want to have a user's iRating show below their name. I want to have the label say {0} iRating (so the string would be 2500 iRating), but if you add that extra text it no longer makes that subwidget because it now technically has data in it. How can I work around this?

Attached image is what's occurring, left is desired behavior, right is bugged when you add the iRating text.

PS something I noticed as I was cropping this screenshot - those blue boxes are supposed to be one extra pixel to the right, and they display correctly in the Theme Editor even after restarting it but it's wrong here for some reason.
Posts: 81
apparently image attachments aren't working right so

Posts: 287
I get this problem many times.

The solution is to do a script with irating coming information and out with variable with your adding text.
Important, to return null if result == null
In that case you get no information in your subwidget when no driver exist and the label disappear.

Hope you understand
Posts: 785
I have fixed this bug for the next release. It should now hide the SubWidget / Label whenever the data from the binding is empty, not just when the displayed text is empty.
Posts: 81
I believe this caused a new issue unfortunately. It seems now that if there's a label without a binding at all (like something used for cosmetic reasons only for example), it's no longer hidden dynamically.

EDIT: Confirmed, I gave a label a binding just to test, and it's now hidden and works like normal.
Edited (1 time)
Posts: 785
Hmm.. you mean if you have a subwidget that has a label with no binding but just some color or something, then the subwidget will not hide anymore? I'll check it out, I thought it was still hiding in my test.
Posts: 785
I have reverted this change and restored the original behavior for now. I tried to implement a proper fix but something is causing it to fail, so to prevent themes from suddenly behaving differently I have temporarily restored the old behavior.

To dynamically hide a label with a 'Text' value, please use the workaround from Emmanuel for now. Sorry for the inconvenience!
Posts: 81
So I've actually still been using 1.37.1.0 until recently, when I accidentally updated, breaking the old dynamic behavior.

Emmanuel explained a script to fix the issue, but I'm not sure how to actually code that. Do you mind explaining a bit simpler?

I swear I need to take a coding class soon so I can stop sounding so clueless.
Posts: 81
hey I mashed something together and it somehow works

using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;

namespace Scripts
{
public class iRatingText : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value == null)
return "";
string output = value + " iRating";
return output.ToString();
}
}
}
Posts: 287
I can show you exemple for put a # before car number and continue to have a dynamic subwidget:
using System;
using ATVO.ThemesSDK;
using ATVO.ThemeEditor.ThemeModels;
using ATVO.ThemeEditor.Scripting.DotNET;
using ATVO.ThemesSDK.Data.Entity;

namespace Scripts
{
public class SC_car_number : IScript
{
public object Execute(ThemeContentItem item, object value, string parameter, ISimulation sim)
{
if (value == null)
{
// do something appropriate, in this case probably just return nothing
return null;
}

// binding ----- car objet dans qualification

ICar result = (ICar) value;

var carN = result.Number;
return "# "+carN;
}
}
}