FG Spreadshirt Swag
  1. #1

    Setting a control's label programmatically

    I'm using a "string_labeled" control, and I want to update the label programmatically. It normally has a child tag, "labelres", that specifies the string resource to use for the label, but I can't figure out how to programmatically specify a string or another string resource.

    Thanks in advance.
    Playing tabletop RPGs since 1983.
    GMing: West Marches (Numenera); Revenge on the Dragon (Cypher System); The Ultimate Cake Recipe (Invisible Sun)
    FG Unity Ultimate License holder
    https://wanderingmonster.org.

  2. #2
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Refer to the Developer Guide -> Ruleset API Reference in the Wiki.

    The stringcontrol guide is here: https://fantasygroundsunity.atlassia.../stringcontrol It inherits the "textbasecontrol" which has setValue - https://fantasygroundsunity.atlassia...ntrol#setValue
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  3. #3
    Quote Originally Posted by paulyhedral View Post
    I'm using a "string_labeled" control, and I want to update the label programmatically. It normally has a child tag, "labelres", that specifies the string resource to use for the label, but I can't figure out how to programmatically specify a string or another string resource.

    Thanks in advance.
    Attach a script to the control or the windowclass depending on where you need to change it. Then reference the control by its name variable (name="THIS") and use THIS.setValue("Whatever this label should be.");

    Also, read what Trenloe posted
    ---
    Fantasy Grounds AD&D Reference Bundle, AD&D Adventure Bundle 1, AD&D Adventure Bundle 2
    Documentation for AD&D 2E ruleset.
    Custom Maps (I2, S4, T1-4, Barrowmaze,Lost City of Barakus)
    Note: Please do not message me directly on this site, post in the forums or ping me in FG's discord.

  4. #4
    I'm looking to set the label, not the value. The value appears above a horizontal line, and a label appears below it. Here's a snippet of the control:
    <string_labeled name="guide_attr">
    <anchored to="guide_skill" width="40" height="20">
    <top />
    <right anchor="left" offset="-5" />
    </anchored>

    <readonly /> <labelres>journey_party_roles_guide_attr_label</labelres>
    <tooltip>journey_party_roles_guide_attr_tooltip</tooltip>
    </string_labeled>


    And what it looks like:
    Screen Shot 2021-03-13 at 21.46.49.png
    It's the "labelres" ("NAME" in the attached image) value that I want to change.
    Attached Images Attached Images
    Playing tabletop RPGs since 1983.
    GMing: West Marches (Numenera); Revenge on the Dragon (Cypher System); The Ultimate Cake Recipe (Invisible Sun)
    FG Unity Ultimate License holder
    https://wanderingmonster.org.

  5. #5

  6. #6
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,362
    Quote Originally Posted by paulyhedral View Post
    I'm looking to set the label, not the value.
    A "string_labeled" control is a template based on the stringcontrol base control. To change the text in that control (the text of the label in this case) you need to change the value of the control with setValue

    So what I and celestian mentioned above is accurate.

    If you're running code within the window where the control is use guide_attr.setValue("my new text"); If you're running code within the label just use setValue("my new text") If you're running code somewhere else in the GUI you'll need to navigate the GUI hierarchy to reach the control.
    Private Messages: My inbox is forever filling up with PMs. Please don't send me PMs unless they are actually private/personal messages. General FG questions should be asked in the forums - don't be afraid, the FG community don't bite and you're giving everyone the chance to respond and learn!

  7. #7
    Quote Originally Posted by Trenloe View Post
    A "string_labeled" control is a template based on the stringcontrol base control. To change the text in that control (the text of the label in this case) you need to change the value of the control with setValue
    Ah, I see. So it's just a matter of figuring out what the label sub-control is called, so I can call setValue on it? Awesome, thanks much!
    Playing tabletop RPGs since 1983.
    GMing: West Marches (Numenera); Revenge on the Dragon (Cypher System); The Ultimate Cake Recipe (Invisible Sun)
    FG Unity Ultimate License holder
    https://wanderingmonster.org.

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
  •  
DICE PACKS BUNDLE

Log in

Log in