STAR TREK 2d20
  1. #1

    Trying to understand token widget behavior

    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.
    Code:
    			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):

    Screen Shot 2022-03-05 at 11.31.38 AM.png

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

    Cheers,
    Brian

  2. #2
    I think this post from 2018 answers my question: https://www.fantasygrounds.com/forum...l=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
    Last edited by MostTornBrain; March 5th, 2022 at 16:55.

  3. #3
    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

  4. #4
    Quote Originally Posted by Moon Wizard View Post
    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

  5. #5
    The Workshop would be the proper place to find out why your extension isn't working like expected.

    https://www.fantasygrounds.com/forum...2-The-Workshop

  6. #6
    Quote Originally Posted by Nylanfs View Post
    The Workshop would be the proper place to find out why your extension isn't working like expected.

    https://www.fantasygrounds.com/forum...2-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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
5E Character Create Playlist

Log in

Log in