PDA

View Full Version : Set Value Of formattedtextcontrol



dulux-oz
October 21st, 2015, 01:58
Call me stupid, but how the hell do you programmatically change the data in a formattedtextcontrol? There does not seem to be a setValue() function (or anything similar).

Moon Wizard
October 21st, 2015, 02:35
The formattedtextcontrol never had getValue/setValue calls, though though support for copying data via databasenode objects using getValue/setValue on the DB objects with the formattedtext type was added last year or so.

Regards,
JPG

dulux-oz
October 21st, 2015, 03:27
Sorry, so does that mean we've got to use a formattedtextfield and modify the linked DB.node?

So how do we get data into a formattedtextcontrol?

Trenloe
October 21st, 2015, 04:14
So how do we get data into a formattedtextcontrol?
Go directly to the database node the control is anchored/sourced. So ,yeah, use a formattedtextfield (a formattedtextcontrol anchored to a database node) and use <formattedtextfield>.getDataBaseNode.SetValue("blah, blah, blah")

https://www.fantasygrounds.com/refdoc/databasecontrol.xcp#getDatabaseNode

Moon Wizard
October 21st, 2015, 04:22
There's no way to do that currently. It would require API changes. I'll look into adding for the next cycle.

Cheers,
JPG

Trenloe
October 21st, 2015, 04:28
There's no way to do that currently. It would require API changes. I'll look into adding for the next cycle.
So, would DB.findNode(<formattedtextfield>.getDataBaseNode.getNodeName()).setValue("<p>Blah, Blah, Blah</p>"); work?

dulux-oz
October 21st, 2015, 04:55
There's no way to do that currently. It would require API changes. I'll look into adding for the next cycle.

Cheers,
JPG

OK, thanks Moon

Moon Wizard
October 21st, 2015, 17:15
Trenloe,

That approach works for formattedtextfield controls since they are linked to a database node. However, the formattedtextcontrol object doesn't have an underlying database node to access. I think this is what Dulux-oz is trying to access.

Cheers,
JPG

Trenloe
October 21st, 2015, 19:12
That approach works for formattedtextfield controls since they are linked to a database node. However, the formattedtextcontrol object doesn't have an underlying database node to access. I think this is what Dulux-oz is trying to access.
Ah, righto. :o

dulux-oz
October 22nd, 2015, 00:58
However, the formattedtextcontrol object doesn't have an underlying database node to access. I think this is what Dulux-oz is trying to access.

Cheers,
JPG

Yeah, that's right.

Just as an interest thing - what use is the formattedtextcontrol object as it stands now (apart from being the super-object for the formattedtextfield - I assume) - is that its only purpose or is there some use for it that doesn't involve getValue()/setValue()? :)

Cheers

Moon Wizard
October 22nd, 2015, 01:09
The original developers envisioned it originally as a read only control for reference data. It's always had less accessibility through the API.

Plus, the output is an XML string object, and there are no built in Lua libraries for manipulating XML.

Cheers,
JPG

dulux-oz
October 22nd, 2015, 01:23
So if it was originally envisioned as a R/O object, how do you get data into the darn thing - because that was what I was trying to use it for?

Moon Wizard
October 22nd, 2015, 02:08
I'm just giving history. I've been patching the control every release to improve functionality to the point where it actually makes sense to have API access.

The only way to populate originally was module data.

Regards,
JPG

dulux-oz
October 22nd, 2015, 03:49
I appreciate the history lesson, and apologize if I came across a bit "strong" - I'm just trying to understand what's happening and what I'm doing wrong / how I've got my wires crossed.

So if the only way to populate it originally was with module data, and module data exists in nodes, then you would need/use a formattedtextfield and not a formattedtextcontrol - correct? But if that is the case then it seems to me that the formattedtextcontrol object has no purpose - apart from the added functionality you have/are putting in.

(So at this point I feel as if I'm the boy who points out that the Emperor is wearing no clothes - or have I missed the point entirely? :) )

Thanks for putting up with some inane questions.

Cheers

damned
October 22nd, 2015, 05:12
(So at this point I feel as if I'm the boy who points out that the Emperor is wearing no clothes - or have I missed the point entirely? :) )

But it was a previous Emperor who implemented that Control.
The Emperor is Dead!
Long live the Emperor!

dulux-oz
October 22nd, 2015, 05:36
But it was a previous Emperor who implemented that Control.
The Emperor is Dead!
Long live the Emperor!

OK, so the Emperor is wearing no coffin :p

Moon Wizard
October 22nd, 2015, 20:09
You are absolutely right about formattedtextcontrol serving little purpose by itself. However, formattedtextfield derives from the control version, just like the other controls. So, it has been improved as well.

Just historical stuff that we work through slowly inline with other requirements.

Cheers,
JPG

dulux-oz
October 23rd, 2015, 02:05
Cool - thanks for the explaination - I'll look forward to the setValue() functionality :)

Cheers

dulux-oz
October 30th, 2015, 04:53
Hmmm, not sure what I'm doing wrong here - the code should explain what I'm trying to do:


local oWindow = Interface.openWindow("referencetextwide","");
if not oWindow then
return;
end
oWindow.header.subwindow.name.setValue("Text Title");
oWindow.text.setValue("Some text");

The last line works, but the 2nd last line spits up an error because the subwindow is nil - a little help please :)

Cheers

Moon Wizard
October 30th, 2015, 06:07
The window instances within a sub window control do not immediately initialize until drawn the first time (i.e. control is visible). The subwindow is null in this case. There's an onSubwindowInstantiated event that fires in that case.

You're probably better off making your own custom window that uses controls instead of fields, and uses the fastinit flag for any subwindows to avoid this scenario.

Regards,
JPG