Copy link to clipboard
Copied
Hi Everyone,
I have fetched the undo history list values by dynamic and tried to bind inside the listbox but in sample sdk the values are bind using kWLBCmpItemBaseKey. Insted of kWLBCmpItemBaseKey i used the widget id to bind the values but it shows an error message. In what way i can bind the history list values for that i have used the following code
WLBCmpTreeViewAdapter::WLBCmpTreeViewAdapter(IPMUnknown* boss) :ListTreeViewAdapter(boss)
{
//initialize the list with the default list string name
K2Vector<PMString> lists;
for (int32 i = 0; i< 12; i++)
{
PMString name(kWLBCmpTextWidgetID);
name.AppendNumber(i + 1);
name.Translate();
lists.push_back(name);
}
InterfacePtr<IStringListData> iListData(this, IID_ISTRINGLISTDATA);
iListData->SetStringList(lists);
I have fetched the history list using
PMString UndoHistory;
InterfacePtr<IScriptManager> scriptManager(Utils<IScriptUtils>()->QueryScriptManager(kJavaScriptMgrBoss));
InterfacePtr<IScriptRunner> scriptRunner(scriptManager, UseDefaultIID());
PMString importScript;
PMString docName;
importScript.Append("var UndoHistory = app.activeDocument.undoHistory;");
importScript.Append("alert(UndoHistory);");
importScript.Append("app.scriptArgs.set(\"UndoHistory\",String(UndoHistory));");
PMString engineName("myengine");
int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, importScript);
UndoHistory = Utils<IScriptArgs>()->Get("UndoHistory");
CAlert::InformationAlert(UndoHistory);
Utils<IScriptArgs>()->Clear();
Now how i Can bind the history list values into listbox, sameway in WListBox Composite plugin there is an option called AddItem i have coded it by clicking the history list gets added for that i used the below code
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;
importScript.Append("var UndoHistory= app.activeDocument.undoHistory;");
importScript.Append("app.scriptArgs.set(\"vUnit\",String(UndoHistory));");
PMString engineName("myengine");
int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, importScript);
UndoHistory= Utils<IScriptArgs>()->Get("UndoHistory");
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 bind the values inside listbox...
-Jothi
Hi Derek,
Thanks for your response.
I have i tried to bind the undo history values into listbox and i have done it.
Now all the undo history actions is displaying at one line inside the listbox.
I need to display the all undohistory actions one by one inside listbox.
I have stored the undohistory values in
PMString history = UndoHistory;
how i can iterate it and bind the history values one by one inside listbox??????
Thanks
-Jothi
app.activeDocument.undoHistory is an array of strings.
When you convert the value into a plain string, iterating that gives you the characters.
To continue with your scripted approach, see IExtendScriptUtils for alternative versions of RunScriptInEngine() supporting a "result" parameter. Your script can pass an array thru that.
Copy link to clipboard
Copied
Hi Experts,
I'm working on sample WListbox Composite SDK plugin.
Is there any way to add dynamic items to the Wlistbox ? I am able to add static items to the list.
If possible, kindly share the information.
Thanks in advance.
Regards,
Victor Prabhu
Copy link to clipboard
Copied
Please describe what you mean with dynamic.
Jothi has above quoted a modified version of WLBCmpActionComponent::DoAddItem which adds an item to its model then notifies the treeMgr about the change via NodeAdded(). As action component this would be invoked by a menu action, is that dynamic enough?
Otherwise, as the "undo history" above is copied from scripting world, you might be looking for a notification that automatically would perform such a change when the undo history changes. Scripting likely does not have such notifications and it would be more difficult to follow them anyway. Therefor I recommended (in a different thread) to bypass scripting and look at the SDK's equivalent. That is, if you're working on Jothi's project.
If you instead want to provide different "dynamic" list items dependent on your data (e.g. change an icon, modify texts), have a look at the TreeViewWidgetMgr.
Copy link to clipboard
Copied
Hi Derek,
Thanks for your response.
I have i tried to bind the undo history values into listbox and i have done it.
Now all the undo history actions is displaying at one line inside the listbox.
I need to display the all undohistory actions one by one inside listbox.
I have stored the undohistory values in
PMString history = UndoHistory;
how i can iterate it and bind the history values one by one inside listbox??????
Thanks
-Jothi
Copy link to clipboard
Copied
app.activeDocument.undoHistory is an array of strings.
When you convert the value into a plain string, iterating that gives you the characters.
To continue with your scripted approach, see IExtendScriptUtils for alternative versions of RunScriptInEngine() supporting a "result" parameter. Your script can pass an array thru that.