-
July 23rd, 2019, 00:51 #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?
-
July 23rd, 2019, 02:45 #2
Archangel
- 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.
-
July 23rd, 2019, 06:43 #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 )
-
July 23rd, 2019, 07:51 #4
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,539
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
-
July 23rd, 2019, 16:12 #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.
-
July 23rd, 2019, 19:02 #6
Supreme Deity
- Join Date
- Mar 2007
- Posts
- 20,539
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
-
July 23rd, 2019, 19:41 #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>
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
Code:<template name="notes_actions"> <buttoncontrol> <anchored to="text" position="insidebottomleft"> <right parent="text" anchor="right" relation="relative" /> </anchored> </buttoncontrol> </template>
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'
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).
-
July 23rd, 2019, 20:20 #8
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!
-
July 23rd, 2019, 21:27 #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
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
-
July 23rd, 2019, 21:32 #10
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