2023-09-25 08:53 AM - last edited on 2024-09-16 02:19 PM by Doreena Deng
Hello
I am trying to create a new Text type label. I want it to be of Text type regardless of whether the default label is of Text or Symbol type. When I use the ACAPI_Element_GetDefaults function to get the default data of the default label, I didn't find a way to modify the default to be Text type label when the default label is of Symbol. If there is another way to create a Text type label whether the default label is of Text or Symbol type I would love to hear about.
I would appreciate any help, thanks
2023-09-25 10:51 PM - edited 2023-09-26 10:21 AM
Hi Yahavsa!
It's a bit tedious to get all the details right when converting a symbol to a text label (or the other way).
I've done the other way around for one of my Add-Ons, but unfortunately I don't have a working example for the direction you need.
Still I think I can give you some starting points of what to look at.
1. You have to change the following members of the retrieved default element:
labelElem.label.labelClass;
labelElem.label.u.head.typeID = API_TextID;
labelElem.label.u.text // Set the members of this! Might help to initialize it first to zero with `= API_TextType{};`
2. You also have to allocate and fill the following memo members (Take a look at the API_LabelID entry for ACAPI_Element_GetMemo)
(char **) textContent
(short **) textLineStarts
(API_ParagraphType **) paragraphs
You find some hints for how to allocate these in the example Element_Test. Especially in the file Element_Basics.cpp.
I think textLineStarts is not necessary for very simple texts.
Hope that gets you started!
2023-09-26 10:20 AM
Hello
I appreciate your quick and detailed reply!
I'll definitely try out the solution you suggested, I'm just wondering if there isn't a simpler way to access the text/autotext label shown in the label object's settings...
Thanks again!
2023-09-27 08:37 PM
I don't think there's a general easy way to set it up.
If your situation allows it though, you could setup a favorite for the text label and get the basic setup then from that with ACAPI_Favorite_Get.
You might also find ACAPI_Favorite_Import and ACAPI_Favorite_Export helpful. Then you could store the favorite as a file and distribute it alongside your Add-On.