Log in

View Full Version : setEditMode and isEditMode in FormattedTextControl



st4lk3r87
July 14th, 2019, 23:57
By looking at the API Documentation the FormattedTextControl have two methods setEditMode and isEditMode. https://www.fantasygrounds.com/refdoc/formattedtextcontrol.xcp

I'm creating a control from code. I'm using a template which is a FormattedTextControl and I'm trying to call these two methods but none of those are valid functions.

I'm not sure if I'm doing all the things correctly.

Template



<template name="wizzy_trait_description_left_column">
<formattedtextcontrol>
<anchored height="60">
<top parent="columnanchor" anchor="bottom" relation="relative" offset="20" />
<left offset="50"/>
<right anchor="center" offset="-15"/>
</anchored>
<invisible/>
</formattedtextcontrol>
</template>


Script



descriptionControl = createControl("wizzy_trait_description_left_column", k.."_trait_description");
descriptionControl.setEditMode(false);

Trenloe
July 15th, 2019, 00:04
descriptionControl = createControl("wizzy_trait_description_left_column", k.."_trait_description");
descriptionControl.setEditMode(false);

window.createcontro (https://www.fantasygrounds.com/refdoc/windowinstance.xcp#createControl)l doesn't return a control. Access the created control with the control name created from k.."_trait_description"

celestian
July 15th, 2019, 00:11
window.createcontro (https://www.fantasygrounds.com/refdoc/windowinstance.xcp#createControl)l doesn't return a control. Access the created control with the control name created from k.."_trait_description"

I'm not sure that's true unless I missing some aspect of what's going on here. I've done this and it works.



local controlInit = createControl("initiative_weapon_ct", sControlInit);
controlInit.setValue(aWeapon.nSpeedFactor);
controlInit.setReadOnly(true);
controlInit.setTooltipText("INITIATIVE");

celestian
July 15th, 2019, 00:13
By looking at the API Documentation the FormattedTextControl have two methods setEditMode and isEditMode. https://www.fantasygrounds.com/refdoc/formattedtextcontrol.xcp

I'm creating a control from code. I'm using a template which is a FormattedTextControl and I'm trying to call these two methods but none of those are valid functions.

I'm not sure if I'm doing all the things correctly.

Template



<template name="wizzy_trait_description_left_column">
<formattedtextcontrol>
<anchored height="60">
<top parent="columnanchor" anchor="bottom" relation="relative" offset="20" />
<left offset="50"/>
<right anchor="center" offset="-15"/>
</anchored>
<invisible/>
</formattedtextcontrol>
</template>


Script



descriptionControl = createControl("wizzy_trait_description_left_column", k.."_trait_description");
descriptionControl.setEditMode(false);



What part is failing? the setEditMode()? You mention 2 but I only see the one.

st4lk3r87
July 15th, 2019, 00:17
What part is failing? the setEditMode()? You mention 2 but I only see the one.

I simplified the code a bit and that doesn't work too.

st4lk3r87
July 15th, 2019, 00:20
I'm not sure that's true unless I missing some aspect of what's going on here. I've done this and it works.



local controlInit = createControl("initiative_weapon_ct", sControlInit);
controlInit.setValue(aWeapon.nSpeedFactor);
controlInit.setReadOnly(true);
controlInit.setTooltipText("INITIATIVE");


Yes. That's what happens to me. if I call setValue it works but if I call isEditMode or setEditMode it doesn't. I also noticed that these two methods are not used at all in coreRPG and 5E

Trenloe
July 15th, 2019, 00:20
So, let's clarify what the issue is. You say "none of these are valid functions" - what feedback do you get? Do you get an error message?

Can you right-click in the formattedtext control and see if the format menu is available or not?

st4lk3r87
July 15th, 2019, 00:22
So, let's clarify what the issue is. You say "none of these are valid functions" - what feedback do you get? Do you get an error message?

Can you right-click in the formattedtext control and see if the format menu is available or not?

I get a nil-error when I try to access the setEditMode.

Trenloe
July 15th, 2019, 00:23
I get a nil-error when I try to access the setEditMode.
What is the exact error, and what is the exact line of code?

celestian
July 15th, 2019, 00:24
I get a nil-error when I try to access the setEditMode.

Try self[k.."_trait_description"].setEditMode(). I think that should work... assuming the control template is actually what you think it is (formattedtext control).
Tho I think the other method should as well.

Moon Wizard
July 15th, 2019, 04:58
The isEditMode/setEditMode functions of the formattedtextcontrol have been deprecated, and need to be removed from the documentation.

If you want to query whether the control is read only, then use the isReadOnly/setReadOnly functions.

Is that what you are trying to do?

Regards,
JPG

st4lk3r87
July 15th, 2019, 08:17
The isEditMode/setEditMode functions of the formattedtextcontrol have been deprecated, and need to be removed from the documentation.

If you want to query whether the control is read only, then use the isReadOnly/setReadOnly functions.

Is that what you are trying to do?

Regards,
JPG

Yes, exactly.
They are not just deprecated so. They are removed.

Thank you!

celestian
July 15th, 2019, 20:09
Yes, exactly.
They are not just deprecated so. They are removed.

Thank you!

I was going to suggest (if the other method didnt work) to try just setting .setReadOnly() but I guess JPG sorted it ;) I've not touched the formattedtext in ages ;(

st4lk3r87
July 15th, 2019, 20:16
I was going to suggest (if the other method didnt work) to try just setting .setReadOnly() but I guess JPG sorted it ;) I've not touched the formattedtext in ages ;(
Yes it's the first time I'm trying to use it.

Thanks to everyone for the support!