Page 1 of 1

mergeTBObjects - positions of objects in group

PostPosted: Fri May 01, 2015 5:57 am
by John Robin Dove
Hi Clifton,
I have just discovered that the objects in groups created by mergeTBObjects are treated differently by different browsers. This causes problems in some of my apps. Please see link below. Were you aware of this?

http://www.mediacours.com/tb_examples/test_positions/index.html

Re: mergeTBObjects - positions of objects in group

PostPosted: Fri May 01, 2015 6:36 am
by Clifton
Once you merge objects, I would no longer rely on the Action Editor top and left properties. Instead use pgTBObjGet() or pgGetStyle() to get position because these functions read from the DOM directly. In the other cases, it is likely that the properties that were defined by ToolBook's export property may no longer sync up properly when exported.

Try using the PowerPac functions to get these positions and see if that is consistent for you.

Without studying this particular scenario, there are several possible reasons for the anomally. But if you set the objects position using pgTBObjSet() BEFORE merging, the the sync may be aligned with ToolBook's internal left and top properties.

Re: mergeTBObjects - positions of objects in group

PostPosted: Fri May 01, 2015 6:43 am
by Clifton
UPDATE:
The anomally seems to exist because when I checked the HTML using developer tools, the group with the green rectangle IS merged, but the other one is NOT. Therefore, the value returned is different for this reason.

Take a close look at your code and make sure your object naming is not causing a conflict.

Re: mergeTBObjects - positions of objects in group

PostPosted: Fri May 01, 2015 6:48 am
by John Robin Dove
I am using pgTBObjectGet(). I'll try pgGetStyle()

I'm pretty sure there are no naming conflicts. The group with the orange rectangle is created by TB in the usual way. The other one is a field and a sub group merged with mergeTBObjects. Shall I send you the tbk?

Re: mergeTBObjects - positions of objects in group

PostPosted: Fri May 01, 2015 8:12 am
by Clifton
Sure, I'll take a look.

Re: mergeTBObjects - positions of objects in group

PostPosted: Fri May 01, 2015 6:04 pm
by Clifton
Thank you for submitting your reduced test case TBK.

NOTE: The correct result when the rectangle is clicked on is 145px. This is because the rectangle's left position is relative to its new parent AFTER mergeTBObjects() is applied. However, since ToolBook does not support this kind of dynamic restructuring of its content, it falls back to its own way of figuring out the position. In non-IE browser it so happens to work correctly, but in IE you get an incorrect, or unexpected, value.

Since you were using pgTBObjGet() to return the left position of the rectangle, you should've been able to get the correct value regardless of browser, etc. However, our port of this function relies on ToolBook's internal function to get this information and thus the bug persisted. I have fixed this for future releases of the PowerPac (v12.332+).

A workaround that works in all browsers is to use the PowerPac function pgGetStyle() as it reads directly from the DOM instead of relying on any internal ToolBook content features.

Re: mergeTBObjects - positions of objects in group

PostPosted: Sat May 02, 2015 4:41 am
by John Robin Dove
You're welcome!