Highlighted

ScriptUI not reliable

Advocate ,
Jun 13, 2019

Copy link to clipboard

Copied

Dear friends,

This time I'm really awake... In my script I check properties of graphic object and update a palette accordingly. I have now discovered, that for certain texts the ScriptUI functions are not reliable - or at least tricky to be used.

  if (Fgr_IsOneOf("Arc Line Polyline", sType)){   // --- Arrow shapes -----------------------------

    wPalP.g0.pArr.gTipNum.pTips.children[0].value = false; // assume no arrow

    kArrow = Fgr_IsArrayInArray (goFgr.ARROWPROPS, [oObject.ArrowBaseAngle, oObject.ArrowTipAngle, oObject.ArrowLength/goFgr.PT, 0.25, oObject.ArrowType]);

    if (kArrow === null) {

      msgText = msgText + "Arrow shape is none of the pre-defined. ";

      wPalP.g0.pArr.current.text = "Current: " + oObject.ArrowBaseAngle + "°, " + oObject.ArrowTipAngle + "°, " + oObject.ArrowLength/goFgr.PT + "pt, " + oObject.ArrowType;

//    wPalP.g0.pArr.current.visible = true;

//    wPalP.g0.pArr.current.graphics.foregroundColor = wPalP.g0.pArr.current.graphics.newPen (wPalP.g0.pArr.current.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);

//    alert (wPalP.g0.pArr.current.text);

    } else {

As you can see from the comment lines I was fiddling around with various hacks to make ...current.text appear. A similar part of the script with no special characters created no problems at all.The script is UTF-8 with BOM encoded and hence the degree symbol is a 2-byte entity.

With the above text I got success only with the additional alert!

Then I started with the text without any degree symbols ➔ OK. Then I succesively added the degree symbols ➔ still OK.

There must have been some strange character code in the string which did not allow to display the text. I could however not recognise this in the editor and may have wiped out this obstacle with the new set up of the string. But why could then an alert kick the text into visibility?

The dialogue looks like this (with the messages in red):

FMgraph_panel_P.png

TOPICS
Scripting

Views

260

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

ScriptUI not reliable

Advocate ,
Jun 13, 2019

Copy link to clipboard

Copied

Dear friends,

This time I'm really awake... In my script I check properties of graphic object and update a palette accordingly. I have now discovered, that for certain texts the ScriptUI functions are not reliable - or at least tricky to be used.

  if (Fgr_IsOneOf("Arc Line Polyline", sType)){   // --- Arrow shapes -----------------------------

    wPalP.g0.pArr.gTipNum.pTips.children[0].value = false; // assume no arrow

    kArrow = Fgr_IsArrayInArray (goFgr.ARROWPROPS, [oObject.ArrowBaseAngle, oObject.ArrowTipAngle, oObject.ArrowLength/goFgr.PT, 0.25, oObject.ArrowType]);

    if (kArrow === null) {

      msgText = msgText + "Arrow shape is none of the pre-defined. ";

      wPalP.g0.pArr.current.text = "Current: " + oObject.ArrowBaseAngle + "°, " + oObject.ArrowTipAngle + "°, " + oObject.ArrowLength/goFgr.PT + "pt, " + oObject.ArrowType;

//    wPalP.g0.pArr.current.visible = true;

//    wPalP.g0.pArr.current.graphics.foregroundColor = wPalP.g0.pArr.current.graphics.newPen (wPalP.g0.pArr.current.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);

//    alert (wPalP.g0.pArr.current.text);

    } else {

As you can see from the comment lines I was fiddling around with various hacks to make ...current.text appear. A similar part of the script with no special characters created no problems at all.The script is UTF-8 with BOM encoded and hence the degree symbol is a 2-byte entity.

With the above text I got success only with the additional alert!

Then I started with the text without any degree symbols ➔ OK. Then I succesively added the degree symbols ➔ still OK.

There must have been some strange character code in the string which did not allow to display the text. I could however not recognise this in the editor and may have wiped out this obstacle with the new set up of the string. But why could then an alert kick the text into visibility?

The dialogue looks like this (with the messages in red):

FMgraph_panel_P.png

TOPICS
Scripting

Views

261

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
Jun 13, 2019 0
Engaged ,
Jun 13, 2019

Copy link to clipboard

Copied

Hi Klaus,

As it works as expected, when you call alert, it sounds like the Dialog simply doesn't refresh/update the layout.

Maybe it's due to the Dialog is very complex, and some Events get lost in space.

Some thoughts, not sure if it works

* Window has a property "layout", an instance of "LayoutManager".

* "LayoutManager has a method "layout()"

* layout() is only called the first time a Dialog appears. After that layout() has to be called by script, if Dialog is resized, etc.

* Maybe it could work, if you call

Window.layout.layout()

just before the script finishes. Where "Window" is the instance of your dialog.

As mentioned, not sure if this helps

markus

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...
Jun 13, 2019 0
K.Daube LATEST
Advocate ,
Jun 13, 2019

Copy link to clipboard

Copied

Thanks Markus,

I'll keep that in the quiver - to be ready if it comes back!

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...
Jun 13, 2019 0