PDA

View Full Version : Why is this still editable on NPC Sheet



Varsuuk
February 7th, 2021, 02:13
I was making changes to the NPC Sheet in a MoreCore extension. I wanted to make the label for "CT Rolls" and "Attributes" be immutable. I took the existing template "
[EDIT: TO BE CLEAR - The template allows editing of the label text BUT it reverts back to the <static> value when you reopen it - which is fine - I just wonder why it just simply doesn't disallow any editing? ]



<template name="string_useredit_bold">
<stringfield>
<font>reference-b</font>
<anchored position="insidetop" offset="0,10" />
<center />
</stringfield>
</template>


and first simply tried:



<template name="string_no_useredit_bold"> <!-- Non-editable version of string_useredit_bold -->
<label>
<font>reference-b</font>
<anchored position="insidetop" offset="0,10" />
<center />
</label>
</template>


(For reference, here is the template "label" from CoreRPG:


<template name="label">
<stringcontrol>
<anchored height="20" />
<font>sheetlabel</font>
<nodrag />
<readonly />
</stringcontrol>
</template>

-- note it has <readonly /> - I even added the readonly to my "no_useredit" template.


But - it still allows editing:


<string_no_useredit_bold name="cas1_label">
<anchored to="cas1" position="insidetop" offset="0,8" height="20" />
<static>CT Rolls</static>
<tooltip textres="label_editable_stats" />
</string_no_useredit_bold>


"static" was originally "default" - I changed it while trying to figure out why I can still click on the label and edit it (on re-open it goes back to CT Rolls) - any ideas what I am missing in the definition?

damned
February 7th, 2021, 11:09
change string_useredit_bold to label
the stringfield vs stringcontrol is probably whats occurring

Varsuuk
February 7th, 2021, 14:29
That’s what I thought Damned, it might have gotten lost in the set of code above but here is the version from above I tried that is confusing me:


<template name="string_no_useredit_bold"> <!-- Non-editable version of string_useredit_bold -->
<label>
<font>reference-b</font>
<anchored position="insidetop" offset="0,10" />
<center />
</label>
</template>


As you see I did change stringcontrol to label. I didn’t simply change user edit to label because label used a different font than useredit. Of course, I can change it to label then change the font as well instead of using a template. I’ll try it to rule that out as the issue but I am not seeing why what I wrote above doesn’t work as read only.

Varsuuk
February 7th, 2021, 16:30
And yes... that WOULD have been enough...

if not for (wait for it.. brain-flatulence example is nigh... ):
cas1_label.setReadOnly(bReadOnly);

calls in onInit()

I was WONDERING how I couldn't get a label to work like a label :). Sorry to waste folk's time.