Skip to main content
Known Participant
November 25, 2024
Answered

Setting document tags (labels?) from C++ to be accesses from JSX

  • November 25, 2024
  • 1 reply
  • 195 views

Hi,

I want to be able to set label on the document from my C++ plugin to that the same can be accessed from the jsx file.

 

IDocument* doc = GetIDocument(...)

UIDRef ownerUID = doc->GetDocWorkSpace();

 

 

 

Later during the persisting command execution I have code similar to the following 

 

	UIDRef owner = GetItemList()->GetRef(0);

	InterfacePtr<IStringData> stringData(this, UseDefaultIID());
	CHECK_BREAK(stringData);

	PMString stringToWrite = stringData->Get();

	InterfacePtr<I> persist(owner, UseDefaultIID());
	CHECK_BREAK(persist);

	persist->SetString(stringToWrite);

	InterfacePtr<IScript> script(owner, UseDefaultIID());
	if (script) {
		PMString key = WrapperUtils<IUtilitiesWrapper>()->MakePMString(L"MyPluginLabelInfo");

		script->SetTag(key, stringToWrite);
	}

 

The 'script' pointer is coming as null while it works perfectly well for Page Items such as Text. What is the correct way to assign Tags (labels?) in the above persist implementation so that the information can be accesses from the jsx script?

Thanks,

Correct answer Dirk Becker

kDocWorkspaceBoss has no IID_ISCRIPT. Use kDocBoss instead - ::GetUIDRef(doc).

Not sure why you run your own command, I'm using IScriptUtils::SetScriptingTag even though setup is a bit convoluted.

1 reply

Dirk BeckerCorrect answer
Legend
November 25, 2024

kDocWorkspaceBoss has no IID_ISCRIPT. Use kDocBoss instead - ::GetUIDRef(doc).

Not sure why you run your own command, I'm using IScriptUtils::SetScriptingTag even though setup is a bit convoluted.