Highlighted

Display the value inside editbox

Explorer ,
May 25, 2020

Copy link to clipboard

Copied

Hi,

In SDK I have used the following code to design the SDK and used JavaScript Functionality. It works fine but I can't able to display the values inside the textbox .Is there is any bug in my code.Please guide me.

StaticTextWidget
(
0, // WidgetId (default=0)
kSysStaticTextPMRsrcId, // RsrcId
kBindNone, // Frame binding
5, 85, 120, 100, // Frame: left, top, right, bottom.
kTrue, kTrue, // Visible, Enabled
kAlignLeft, kEllipsizeEnd,kTrue, // Alignment, ellipsize style
"kBPIUIWordCountStaticTextKey", // Initial text.
0 // No associated widget
),

// TextEditBox Widget resource
TextEditBoxWidget
(
kWordCountTextEditBoxWidgetID, // WidgetId
kSysEditBoxPMRsrcId, // RsrcId
kBindNone, // Frame binding
Frame(104, 85, 290, 100), // Frame (l,t,r,b)
kTrue, kTrue // Visible, Enabled
0, // Widget id of nudge button (0 so we dont get one)
0, 0,// small,large nudge amount
0, // max num chars(0 = no limit)
kFalse,// is read only
kFalse,// should notify each key stroke
kFalse,// range checking enabled
kFalse,// blank entry allowed
0, // Upper bounds
0, // Lower bounds
"", // Initial text
),

do{

PMString kWordCountTextEditBoxWidgetID = Utils<IScriptArgs>()->Get("kBPIUIWordCountStaticTextKey");

Utils<IScriptArgs>()->Set("kBPIUIWordCountStaticTextKey", kWordCountTextEditBoxWidgetID);


PMString ScriptCode;

ScriptCode.Append("var kBPIUIWordCountStaticTextKey =0;");
ScriptCode.Append("for(var i =0; app.activeDocument.stories.length>i; i++)");
ScriptCode.Append("{");
ScriptCode.Append("kBPIUIWordCountStaticTextKey += app.activeDocument.stories[i].words.length;");
ScriptCode.Append("}");
ScriptCode.Append("alert( 'Word Count    : ' + WC);");

ScriptCode.Append("if (app.scriptArgs.isDefined(kBPIUIWordCountStaticTextKey))");
ScriptCode.Append("{");
ScriptCode.Append("var kWordCountTextEditBoxWidgetID = app.scriptArgs.get(kBPIUIWordCountStaticTextKey);");
ScriptCode.Append("}");


PMString engineName("myengine");

int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, ScriptCode);
Utils<IScriptArgs>()->Clear();
} while (false);

Nithu
TOPICS
How to, Scripting, SDK

Views

413

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 the value inside editbox

Explorer ,
May 25, 2020

Copy link to clipboard

Copied

Hi,

In SDK I have used the following code to design the SDK and used JavaScript Functionality. It works fine but I can't able to display the values inside the textbox .Is there is any bug in my code.Please guide me.

StaticTextWidget
(
0, // WidgetId (default=0)
kSysStaticTextPMRsrcId, // RsrcId
kBindNone, // Frame binding
5, 85, 120, 100, // Frame: left, top, right, bottom.
kTrue, kTrue, // Visible, Enabled
kAlignLeft, kEllipsizeEnd,kTrue, // Alignment, ellipsize style
"kBPIUIWordCountStaticTextKey", // Initial text.
0 // No associated widget
),

// TextEditBox Widget resource
TextEditBoxWidget
(
kWordCountTextEditBoxWidgetID, // WidgetId
kSysEditBoxPMRsrcId, // RsrcId
kBindNone, // Frame binding
Frame(104, 85, 290, 100), // Frame (l,t,r,b)
kTrue, kTrue // Visible, Enabled
0, // Widget id of nudge button (0 so we dont get one)
0, 0,// small,large nudge amount
0, // max num chars(0 = no limit)
kFalse,// is read only
kFalse,// should notify each key stroke
kFalse,// range checking enabled
kFalse,// blank entry allowed
0, // Upper bounds
0, // Lower bounds
"", // Initial text
),

do{

PMString kWordCountTextEditBoxWidgetID = Utils<IScriptArgs>()->Get("kBPIUIWordCountStaticTextKey");

Utils<IScriptArgs>()->Set("kBPIUIWordCountStaticTextKey", kWordCountTextEditBoxWidgetID);


PMString ScriptCode;

ScriptCode.Append("var kBPIUIWordCountStaticTextKey =0;");
ScriptCode.Append("for(var i =0; app.activeDocument.stories.length>i; i++)");
ScriptCode.Append("{");
ScriptCode.Append("kBPIUIWordCountStaticTextKey += app.activeDocument.stories[i].words.length;");
ScriptCode.Append("}");
ScriptCode.Append("alert( 'Word Count    : ' + WC);");

ScriptCode.Append("if (app.scriptArgs.isDefined(kBPIUIWordCountStaticTextKey))");
ScriptCode.Append("{");
ScriptCode.Append("var kWordCountTextEditBoxWidgetID = app.scriptArgs.get(kBPIUIWordCountStaticTextKey);");
ScriptCode.Append("}");


PMString engineName("myengine");

int32 errorCode = Utils<IExtendScriptUtils>()->RunScriptInEngine(engineName, ScriptCode);
Utils<IScriptArgs>()->Clear();
} while (false);

Nithu
TOPICS
How to, Scripting, SDK

Views

414

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
May 25, 2020 0
Adobe Community Professional ,
May 25, 2020

Copy link to clipboard

Copied

Nithu,

 

The same query was posted by another user named Monisha, i composed an answer and before i could post it the query was deleted and here you are again with the same question. I have pointed this before as well, posting the same question from different account will not elicit a different response. The answer remains the same, so kindly refrain from posting the same question multiple time via different accounts(i recount there are 3 accounts working in sync here), else we will have to report/ban these acounts for creating spam on the forum.

 

Now regarding the query you posted. Where have you written the code to actually show some value in the static text. You have shown you snippet for fr file which does not show where you have used this static text, on a panel/dialog etc. So we are not sure that the widget is shown in the first place or not. Assuming its shown, you will have to decide how to pass on the value that the script return to it, here it gets complex. Generally ID programming does not working in conventional way, you have to get to the actual class that has the method that does what you want. So in this case you will have to get to the interfaces bound on the static text and then call the method to set it. For that you will first have to get to the parent of this widget. There are some other design patterns in play as well, that depends upon your workflow. A simple one would be this static text is inside a dialog(kDialogboss), so you will call your script from the controller of the dialog and initialize the widget there. You could also trigger this in response to an event etc. 

 

As i have mentioned before you will have to learn the sdk, there are not shortcuts. If you keep posting questions with the hope to get the code you could paste, you are wasting your time. Be assured this will never happen for ID C++ sdk.

 

Bonus tip :- Using JSX for what you are doing makes very little sense, if you have to write jsx what is the point of creating a C++ plugin in the first place. The s/w you are architecturing is totally misplaced in my opinion. If you have jsx, create the UI using ScriptUI or an CEP extension. If you have a need for a complex native UI that only C++ can generate then i would suggest be clean and code everything in C++ 

-Manan

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
Reply
Loading...
May 25, 2020 4
Explorer ,
May 25, 2020

Copy link to clipboard

Copied

Hi,

I'll check your reference and I don't find any queies which is similar to my post so that I have used this community to find my query.

Nithu

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
Reply
Loading...
May 25, 2020 0
Adobe Community Professional ,
May 25, 2020

Copy link to clipboard

Copied

See the screegrab below of the post made by the account which i pointed. Same question within the same time frame with almost the same language itself and still you are saying as if i am mistaken

https://www.dropbox.com/s/dqz5gwblik8vokz/screen%20recording%202020-05-25%20at%208.10.31%20pm.mov?dl...

 

Then there are other instances as well, i see around 3-4 people are working on the same workflow of calling JSX from C++, and seem to have the same problem and then post it out first individually and then in some cases multiple times by one account as well. And interestingly most of these queries are dropped dead in between or just marked correct at the first response

 

-Manan

 

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
Reply
Loading...
May 25, 2020 1
Nithu_S LATEST
Explorer ,
May 25, 2020

Copy link to clipboard

Copied

But before posting my query I have reviewed all the post which is posted in the community by that time I won't find the post which you have shared with me. Yeah, you are right, I too find some queries based on plugin creation using Javascript functionalities but they have asked for some queries but the query has been terminated within two or three replies So that I have created more post with same queries.

Nithu

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
Reply
Loading...
May 25, 2020 0