Highlighted

Display list inside listbox

Explorer ,
Jul 19, 2020

Copy link to clipboard

Copied

Hi Proessionals,

I'm working on sample WLisbox sdk and during add item i tried to bind the undo history values into listbox and i have done it. but, now the list of history actions is displaying at same line i need to display the actions at array for that i have iterated it and brought the history at one by one in alert using script and then i have passed the value through sciptargs after build, only the last action of the history gets binded inside listbox, for that i have used the below code please do guide me to display all the actions inside listbox


/* DoAddItem
*/
void WLBCmpActionComponent::DoAddItem(IPMUnknown *invokedWidget)
{
InterfacePtr<IControlView> treeWidget(static_cast<IControlView*>(Utils<IWidgetUtils>()->QueryRelatedWidget(invokedWidget, kWLBCmpListBoxWidgetID, IID_ICONTROLVIEW)));
InterfacePtr<ITreeViewMgr> treeMgr(treeWidget, UseDefaultIID());
InterfacePtr<IStringListData> iListData(treeWidget, IID_ISTRINGLISTDATA);
K2Vector<PMString> lists = iListData->GetStringList();
PMString undoHistory;
InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
PMString importScript;
PMString docName;

importScript.Append("var undo = app.activeDocument.undoHistory;");
importScript.Append("for(var j=undo.length-1; j>=0; j--)");
importScript.Append("{");
importScript.Append("var result = undo[j];");
importScript.Append("alert(result);");
importScript.Append("app.scriptArgs.set(\"result\",String(result));");
importScript.Append("}");
PMString engineName("myengine");
int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, importScript);
undoHistory = Utils<IScriptArgs>()->Get("result");
//CAlert::InformationAlert(vUnit);
Utils<IScriptArgs>()->Clear();
PMString item(undoHistory);
item.Translate();
K2Vector<PMString>::const_iterator iter = std::find(lists.begin(), lists.end(), item);
int32 addIndex = 2;
while (iter != lists.end())
{
item.Insert("+ ", 2, 2);
iter = std::find(lists.begin(), lists.end(), item);
}

if (iter == lists.end())
{
lists.insert(lists.begin(), item);
iListData->SetStringList(lists);
//make sure that the node added has been processed
NodeID node = WLBCmpNodeID::Create(item);
treeMgr->NodeAdded(node);
}
}

please guide me to display the hitory in list inside listbox.

 

-Jothi

TOPICS
Scripting, SDK, Server developers

Views

39

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Display list inside listbox

Explorer ,
Jul 19, 2020

Copy link to clipboard

Copied

Hi Proessionals,

I'm working on sample WLisbox sdk and during add item i tried to bind the undo history values into listbox and i have done it. but, now the list of history actions is displaying at same line i need to display the actions at array for that i have iterated it and brought the history at one by one in alert using script and then i have passed the value through sciptargs after build, only the last action of the history gets binded inside listbox, for that i have used the below code please do guide me to display all the actions inside listbox


/* DoAddItem
*/
void WLBCmpActionComponent::DoAddItem(IPMUnknown *invokedWidget)
{
InterfacePtr<IControlView> treeWidget(static_cast<IControlView*>(Utils<IWidgetUtils>()->QueryRelatedWidget(invokedWidget, kWLBCmpListBoxWidgetID, IID_ICONTROLVIEW)));
InterfacePtr<ITreeViewMgr> treeMgr(treeWidget, UseDefaultIID());
InterfacePtr<IStringListData> iListData(treeWidget, IID_ISTRINGLISTDATA);
K2Vector<PMString> lists = iListData->GetStringList();
PMString undoHistory;
InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
PMString importScript;
PMString docName;

importScript.Append("var undo = app.activeDocument.undoHistory;");
importScript.Append("for(var j=undo.length-1; j>=0; j--)");
importScript.Append("{");
importScript.Append("var result = undo[j];");
importScript.Append("alert(result);");
importScript.Append("app.scriptArgs.set(\"result\",String(result));");
importScript.Append("}");
PMString engineName("myengine");
int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, importScript);
undoHistory = Utils<IScriptArgs>()->Get("result");
//CAlert::InformationAlert(vUnit);
Utils<IScriptArgs>()->Clear();
PMString item(undoHistory);
item.Translate();
K2Vector<PMString>::const_iterator iter = std::find(lists.begin(), lists.end(), item);
int32 addIndex = 2;
while (iter != lists.end())
{
item.Insert("+ ", 2, 2);
iter = std::find(lists.begin(), lists.end(), item);
}

if (iter == lists.end())
{
lists.insert(lists.begin(), item);
iListData->SetStringList(lists);
//make sure that the node added has been processed
NodeID node = WLBCmpNodeID::Create(item);
treeMgr->NodeAdded(node);
}
}

please guide me to display the hitory in list inside listbox.

 

-Jothi

TOPICS
Scripting, SDK, Server developers

Views

40

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 19, 2020 0

Have something to add?

Join the conversation