DICE PACKS BUNDLE
Page 1 of 3 123 Last
  1. #1

    getSelection/setSelection in FormattedTextField?

    In any textbasecontrol, you can get the selection location and set it, using getSelectionPosition() and setSelectionPosition() https://www.fantasygrounds.com/refdo...asecontrol.xcp

    But formmatedtextfields don't seem to respond to those messages, and the documentation doesn't offer any solution. https://www.fantasygrounds.com/refdo...extcontrol.xcp

    Is there no way to programmatically read and set the position in a formatted text field?

  2. #2

    Join Date
    Apr 2008
    Location
    Virginia Beach
    Posts
    3,096
    It has been on the wish list a long time but there is no capability to manipulate the selection for formattedtext.

  3. #3
    Well fudge.... fudge, fudge, fudge.

    I have implemented embedded dice rolling for StringTextFields, useful for the GURPS Ruleset. For example, certain Disadvantages have a "Control Roll". A number that you must roll under or that disadvantage triggers, for example:
    1.png

    And when you hover, it will highlight the "actionable" section, and allow you to double click, which will perform the roll:
    2.png

    And I had planned on adding it to the FormattedTextField, since this contains the descriptions. Certain magic systems in GURPS don't use the standard Spell data structure, and instead implement the magic as a "power" (an advantage with modifiers). In most cases, this is very free form, and there is no standard way to determine what must be rolled. If I could port the StringTextFields code to the FormatedTextField, the author of the "power", could embed the various rolls that are required in the description.

    What is the likelihood that enhancements to FormatedTextField would happen? (I am a Unity backer... in case that adds any clout )

  4. #4
    There are no plans at this point to add additional APIs to any controls other than the image controls for initial FGU development. There's already a ton of work for our small team with all the other library replacements we did as part of Unity, as well as completely rewritten image controls.

    Regards,
    JPG

  5. #5
    As a long time developer (since '85) and the sole developer on a mission critical application (that has a 4-9s uptime requirement), I COMPLETELY understand about "a ton of work". And, I understand the complexity of dealing with a selection point, vs a selection index, it is not an "easy" fix. It just would have looked cool

    I've already dreamed up a "hack-around". I am going to scan the text and add buttons to the bottom of the window for each section of text that would have been highlight-able. It won't look as cool, but it will get the job done, which is to make the players lives easier.

  6. #6
    Good idea. Might be an interesting idea for me to look at eventually; especially if they can be manually specified/overwritten to deal with natural language not easily parsed.

    Regards,
    JPG

  7. #7
    Ok, here is my next problem. I am a pretty good backend developer... but GUIs are not my thing.

    I want to add buttons to the bottom of the "charnote" window class. As you can see from the picture, it creates 4 buttons ([ST6], [DX-2], [CR:12] & [2d-1]), all on top of each other . The text [Attractive, +4] does not match any of the "actionable" patterns, so it isn't included.

    1.png

    Code:
    <windowclass name="charnote">
    		<frame>storybox</frame>
    		<placement>
    			<size width="300" height="300" />
    		</placement>
    		<sizelimits>
    			<minimum width="300" height="300" />
    			<dynamic />
    		</sizelimits>
    		<minimize>minimized_note</minimize>
    		<playercontrol />
    		<nodelete />
    		<tooltip field="name" />
    		<sheetdata>
    			
    			<link_story>
    				<class>charnote</class>
    			</link_story>
    			
    			<genericcontrol name="rightanchor">
    				<anchored height="0" width="0">
    					<top offset="28" />
    					<right offset="-14" />
    				</anchored>
    			</genericcontrol>
    			
    			<stringfield name="name">
    				<anchored to="rightanchor" height="24">
    					<top offset="-4" />
    					<left parent="" offset="45" />
    					<right anchor="left" relation="relative" offset="-5" />
    				</anchored>
    				<font>reference-h</font>
    				<nodrag />
    			</stringfield>
    			
    			<ft_record name="text">
    				<bounds>25,85,-25,-15</bounds>
    				<multilinespacing>16</multilinespacing>
    				<font>reference-r</font>
    				<selectioncolor>#FFD296</selectioncolor>
    				<script file="campaign/scripts/noteshovercheck.lua" />
    			</ft_record>
    			
    			<scrollbar>
    				<anchored to="text" />
    				<target>text</target>
    			</scrollbar>
    
    			<resize_storybox />
    			<close_storybox />
    		</sheetdata>
    	</windowclass>
    So what is the best way to programmatically add buttons? I have been trying a script (the poorly named "noteshovercheck.lua") in the "ft_record" that iterates over the text, determines which things should be "actionable" and stores them in "aAbilities", and tries to create buttons:

    Code:
    function buildButtons()
      if #aAbilities == 0 then return; end
      local parent = "text";
      for i, a in pairs(aAbilities) do
        local bn = "b"..i;
        Debug.console("Button", bn, a.orig);
        
        buttons[i] = window.createControl("notes_actions", bn);
        buttons[i].setAnchor("top", parent, "bottom");
        parent = bn;
        buttons[i].setText(a.orig);
       end
    end
    Where "notes_actions" is:

    Code:
    <template name="notes_actions">
    		<buttoncontrol>
    				<anchored to="text" position="insidebottomleft">
    					<right parent="text" anchor="right" relation="relative" />
    				</anchored>
    		</buttoncontrol>
    	</template>
    It reports:
    Code:
    Runtime Notice: s'Button' | s'b1' | s'ST6'
    Runtime Notice: s'Button' | s'b2' | s'DX-2'
    Runtime Notice: s'Button' | s'b3' | s'CR:12'
    Runtime Notice: s'Button' | s'b4' | s'2d-1'
    But that just smashes all of the buttons on top of each other. I assume there is a way to get one button to build below the other, but I couldn't figure it out (and I resorted to trying to use each successive button as the anchor for the next... which failed, of course).

    So any help would be greatly appreciated. I even thought of creating 10 or so invisible buttons in the XML, and just making visible the ones I use, but that is a last (hacky) resort.

    Once I get them laid out, I can hook them all up.... it is just that the layout stuff is hard (and my search-fu not so good, I guess).

  8. #8
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    In the .setAnchor command you're no longer using the "relative" relation, so each new control will just use basic anchoring - they won't be able to align themselves relative to each other.
    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!

  9. #9
    Unfortunately, nothing changed. I tried:

    Code:
    function buildButtons()
      if #aAbilities == 0 then return; end
      local parent = "text";
      for i, a in pairs(aAbilities) do
        local bn = "b"..i;
        Debug.console("Button", bn, a.orig);
        
        buttons[i] = window.createControl("notes_actions", bn);
        buttons[i].setAnchor("top", parent, "bottom", "relative");
        parent = bn;
        buttons[i].setText(a.orig);
       end
    end
    And then I tried basing it all from "text" (and not changing the parent, hoping the relative keyword would do some magic):

    Code:
    function buildButtons()
      if #aAbilities == 0 then return; end
      local parent = "text";
      for i, a in pairs(aAbilities) do
        local bn = "b"..i;
        Debug.console("Button", bn, a.orig);
        
        buttons[i] = window.createControl("notes_actions", bn);
        buttons[i].setAnchor("top", parent, "bottom", "relative");
        --parent = bn;
        buttons[i].setText(a.orig);
       end
    end
    Same results. The button text appears, but it is all overlaied on top of each other.

  10. #10
    Trenloe's Avatar
    Join Date
    May 2011
    Location
    Colorado, USA
    Posts
    33,402
    You need to check on exactly how relative anchoring works. Some info in the section here: https://www.fantasygrounds.com/wiki/...face#Anchoring

    To have the buttons align next to each other horizontally you'll need to use relative anchoring on the left/right side of the control, to the side of an anchor on the edge of the window. Then you line the controls out from that anchor, with the side edge of each control being relative to the side anchor.

    It's a really powerful piece of functionality that allows controls to dynamically align based off other controls being added (or removed).
    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!

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
  •  
Starfinder Playlist

Log in

Log in