mergeTBObjects - positions of objects in group

Help for using specific functions

mergeTBObjects - positions of objects in group

Postby John Robin Dove » Fri May 01, 2015 5:57 am

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
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: mergeTBObjects - positions of objects in group

Postby Clifton » Fri May 01, 2015 6:36 am

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.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: mergeTBObjects - positions of objects in group

Postby Clifton » Fri May 01, 2015 6:43 am

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.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: mergeTBObjects - positions of objects in group

Postby John Robin Dove » Fri May 01, 2015 6:48 am

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?
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: mergeTBObjects - positions of objects in group

Postby Clifton » Fri May 01, 2015 8:12 am

Sure, I'll take a look.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: mergeTBObjects - positions of objects in group

Postby Clifton » Fri May 01, 2015 6:04 pm

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.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: mergeTBObjects - positions of objects in group

Postby John Robin Dove » Sat May 02, 2015 4:41 am

You're welcome!
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am


Return to Function Help

Who is online

Users browsing this forum: No registered users and 3 guests

cron