PDA

View Full Version : Trying to understand token widget behavior



MostTornBrain
March 5th, 2022, 16:43
Hi,

Not sure if this is the prpoer forum for this question - I'm trying to modify the token health bar display via an extension and I am seeing a behavior I don't understand. I have created a second white colored health bar widget that will be displayed under the normal percentage health bar, to show the original 100% full bar length. The following code visually does it, but the hover text describing the wound level no longer appears.

if bAddBar then
local widgetHealthBar = aWidgets["healthbar"];
if not widgetHealthBar then
widgetHealthBar = tokenCT.addBitmapWidget("healthbar");
widgetHealthBar.bringToFront();
widgetHealthBar.setName("healthbar");
end

local widgetHealthBarFrame = aWidgets["healthbarframe"];
if not widgetHealthBarFrame then
widgetHealthBarFrame = tokenCT.addBitmapWidget("healthbar");
widgetHealthBarFrame.sendToBack();
widgetHealthBarFrame.setName("healthbarframe");
end

if widgetHealthBar then
widgetHealthBar.bringToFront();
widgetHealthBar.setColor(sColor);
widgetHealthBar.setTooltipText(sStatus);
widgetHealthBar.setVisible(sOptTH == "bar");
updateHealthBarScale(tokenCT, nodeCT, nPercentWounded);
end

if widgetHealthBarFrame then
widgetHealthBarFrame.sendToBack();
widgetHealthBarFrame.setVisible(sOptTH == "bar");
end


end

If I call "sendToBack()" instead of "bringToFront()" for the widgetHealthBar, then the hover text works, but then the real health bar is visually hidden behind the widgetHealthBarFrame. Is the lowest level widget in the drawn stack supposed to be the one that triggers the hover text? If so, I suppose I need to do something different. This is the effect I am trying to create (which currently works, minus the hover text support):

51840

Thank you for any clarification on what I am doing wrong.

Cheers,
Brian

MostTornBrain
March 5th, 2022, 16:51
I think this post from 2018 answers my question: https://www.fantasygrounds.com/forums/showthread.php?46652-Widget-Tooltip-stacking&p=415306&viewfull=1#post415306

I assume this applies to FGU as well - i.e. the lowest in the stack (first) generates the hover text.

Sorry, I should have tried searching longer before posting my question.

[EDIT] Hmmm... but this sentence from that post makes me think it was going to change to be top-most: " It should probably be the other way around (i.e. topmost widget), so I'll get that updated for v3.3.7." Anyone know if there was a reason it didn't - or is FGU different from FGC in this regard? Or am I doing something wrong in my implementation?

Cheers,
Brian

Moon Wizard
March 5th, 2022, 17:54
I'm not sure without digging into the code; but it's not something currently on our list to dig into or investigate at this point. So, I would work around the behavior for now; perhaps add the health status to both widgets?

Regards,
JPG

MostTornBrain
March 5th, 2022, 18:00
I'm not sure without digging into the code; but it's not something currently on our list to dig into or investigate at this point. So, I would work around the behavior for now; perhaps add the health status to both widgets?


Thanks! I hadn't thought of adding the status to both widgets. That should actually be better than what I was originally trying to do since the hover area will be the whole bar.

Cheers,
Brian

Nylanfs
March 6th, 2022, 00:13
The Workshop would be the proper place to find out why your extension isn't working like expected. :)

https://www.fantasygrounds.com/forums/forumdisplay.php?42-The-Workshop

MostTornBrain
March 6th, 2022, 01:47
The Workshop would be the proper place to find out why your extension isn't working like expected. :)

https://www.fantasygrounds.com/forums/forumdisplay.php?42-The-Workshop

Thanks - I'll post these type of Lua/API nuance questions in the Workshop from now on. I originally misunderstood the focus of that forum and thought it was only for people making new rulesets.
I'm still fairly new to all that is FG and often find myself lost in the wrong forum. :-)

Cheers,
Brian