PDA

View Full Version : string_labeled



Paul Pratt
June 29th, 2017, 08:46
I am using the Options manager to set the visibility of a few stringcontrols, it works fine for most of what I am changing, except for the strings that use the xml tag "string_labeled". The control shows/hides, well the line shows/hides, but the label does not. The label, when the line is shown, is missing.

I am using this:

function updateDisplay()
local bShow = OptionsManager.isOption("CGS", "dh1");
setVisible(bShow);
end

Any ideas on why the label is suppressed?

Nickademus
June 29th, 2017, 11:05
We'll need a bit more information than that. Where are you putting that function? Are you setting the visibility of the control and the label separately? Are you affecting the string_labeled template or the instance of it?

Paul Pratt
June 29th, 2017, 15:32
"string_labeled" is an xml tag that contains its own label. The function is in the control in the xml sheet. It works, with the exception of suppressing the "label" of the "string_labeled" tag. I see the line, can enter text, but the label below the line is removed. I am just reaching out to see if anyone has any experience with the string_labeled tag and its properties.

Trenloe
June 29th, 2017, 15:46
Is that code you're using set as a <script> entry within the XML of the control based on the template? I'm guessing you are, as you are using setVisible without the control name. If so, that will override the <script> in the template, which is used to construct the label text widget:


<template name="string_labeled">
<stringfield>
<font>sheettext</font>
<lineoffset default="on">1</lineoffset>
<script>
labelwidget = nil;

function onInit()
if labelres then
labelwidget = addTextWidget("sheetlabelinline", string.upper(Interface.getString(labelres[1])));
else
labelwidget = addTextWidget("sheetlabelinline", string.upper(label[1]));
end
if labelwidget then
local w,h = labelwidget.getSize();
labelwidget.setPosition("bottomleft", w/2, h/2-4);
end
end
</script>
</stringfield>
</template>

Paul Pratt
June 30th, 2017, 02:33
Thank you. That is exactly what is happening. I had a feeling it was the string_labeled template, so I went looking for it to check. I couldn't find it in CORErpg. That is when I came here to question what string_label was doing.

Was it in CORE and I missed it?

Nickademus
June 30th, 2017, 02:46
CoreRPG\campaign\template_char.xml