MergeTBObjects CreateDraggableObject disappearing button

Help for using specific functions

MergeTBObjects CreateDraggableObject disappearing button

Postby John Robin Dove » Fri Nov 28, 2014 3:31 pm

Hi I am using MergeTBObjects and CreateDraggableObject in a similar way to that described in my post below. This particular group contains one field that uses pgGotoURL to display a CKEditor word processor pad and another that contains virtual keyboards for certain languages. Despite the complexity, all this works well, so far... My problem is with a button which is part of the group. If I click on it it disappears! And if I try to change its position with either Toolbook or Powerpac it also disappears! Because I vaguely remembered this happening before in another project, I replaced the button with a field. The field does not disappear like the button and behaves as planned (except that it doesn't invert as a button would). I have checked that the button's visible property remains true and I have also tried bringing it to the front to no avail. I'm testing with Google Chrome. It's not a big deal and if necessary the project can stay like this but it does look rather like a bug. I can send the files if this would help.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby Clifton » Mon Dec 01, 2014 3:27 pm

I tried this and could not duplicate the issue. This may be either a ToolBook version 9 anomaly or something else could be causing the behavior. You might try adjusting the sequence of using the functions. Generally use mergeTBObjects() first and createDraggableObject() as the last step in your actions code. It may also be prudent to apply a little delay after merging the objects and before applying createDraggableObject() to prevent strange behaviors with complex layouts. In the worst case scenario, keep those objects that exhibit strange behaviors out of the merge. ToolBook buttons are strange objects and are somewhat different in how they are created between ToolBook versions.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby John Robin Dove » Tue Dec 02, 2014 5:47 am

Thanks for your efforts Clifton. I've tried delaying the CreateDraggableObject action by activating it after all the rest with an onFirstIdle action but it makes no difference. Here's a demo of the strange behavior. http://www.mediacours.com/simulation/pad5/index.html The button actually has an action sequence but it never fires. The button just disappears. Perhaps it is a Toolbook 9 issue as you say. I have another plan to solve the problem but I don't know whether it'll work or not. I'll let you know.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby Clifton » Tue Dec 02, 2014 8:57 am

Ahh! I see the issue!
Your button is moving out of view after clicking on it. It doesn't hide, it moves outside the boundary of the merged group of objects. This causes it to appear hidden when really it is just outside the boundaries for the group. When mergeTBObjects() is executed, it is designed by default to hide objects outside the initial boundaries of the merge (the css style is "overflow:hidden;"). You need to check your actions to see why the button is moving out of view after clicking on it. Otherwise your page seems to be working perfectly. The function allows to you set "overflow:scroll;" or "overflow:visible;" for merged objects, but there is no reason to do this in your application as it just seems that you have a position action that is causing the rogue behavior.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby John Robin Dove » Tue Dec 02, 2014 10:36 am

But why, in that case, does the problem not exist if I replace the button with a TB field of the same dimensions in the same position?

My plan B did not really work. I made an identical button on a separate html page and used pgGoToUrl to display it. No problems with displaying it and clicking on it triggers the appropriate response in the Toolbook part of the app but it has the unwanted side effect of taking the focus away from the CKEditor. So I'm still stuck at the moment.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby Clifton » Tue Dec 02, 2014 7:43 pm

The button is not actually hiding when clicked. It only appears hidden because its position has been changed by some action. When an object is merged with another one, you can no longer use the Action Editor positioning commands on the object because the position is relative to the location of the merged group and the Actions Editor always uses positioning relative to the page. This is not a bug, rather it is a feature of how HTML works when objects are set as children of parent objects on the page. In this case the parent is the object that defines the bounds of the merged object or it is the bounds set by the entire group of merged objects. Thus, if your button is at 100 x 100 when mergeTBobjects() is executed and the entire area defined by the group of merged objects has a x/y position of 50 x 50 relative to the page, then your button position is now fixed at 50 x 50 relative to where the merged objects are located. If you move the button to 100 x 100 it will actually move down and left by 50 pixels because the merged area is already offset by 50 x 50 even though the button was at 100 x 100 relative to the page. Positioning using the actions editor must now take into consideration the relative place of the merged objects. This may explain the disappearing button issue.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby John Robin Dove » Wed Dec 03, 2014 8:27 am

I see, I think. The top and left properties of an object in a group made by mergeTBObjects are relative to those of the group (as is the case with objects on a panel in Visual Studio e.g. a button on a panel is 150 pixels from the top of the window but its top property is 50 because the panel is 100 pixels from the top of the window). However, if this is the case for a button why is it not also the case for a field? And why does clicking on a button affect its position properties? I think I shall use a field because the group will be hidden as soon as it's clicked and the fact that it doesn't invert will be imperceptible.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby John Robin Dove » Wed Dec 03, 2014 9:35 am

Re comment above about button and field I think the field is affected in the same way as the button but I was never able to see where the button was moved to whereas I can see the field in the wrong place.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby Clifton » Thu Dec 04, 2014 9:36 am

It may be that the button is being repositioned by the invert property when clicked. If that is the case, then ToolBook is using the absolute position of the button to move it when it gets inverted on click. You should probably use a different button style to prevent this anomaly. I've not noticed this in later ToolBook versions but the problem may exist in later versions too. This may explain why a field does not exhibit the same behavior.

A workaround to fool the ToolBook system with merged objects may be to include a little field in the group of merged objects and set its position at 0,0 on the page. This will force all positions in the final merged group of objects to share the same relative positions before and after the merge.
Clifton
Site Admin
 
Posts: 732
Joined: Tue Jan 14, 2014 1:04 am

Re: MergeTBObjects CreateDraggableObject disappearing button

Postby John Robin Dove » Thu Dec 04, 2014 1:19 pm

Thanks for the tip Clifton. I have now achieved what I wanted to do and I am quite pleased with the combination of Toolbook, Powerpac and CKEditor. I think I have eliminated all the bugs in this version http://www.mediacours.com/simulation/pad10/index.html The fact that the button is a field and not a button is absolutely not a problem because the (fake) window is hidden immediately the field is clicked so the user can't see whether it's a button or not.

BTW if you received the version I sent in a zip it has numerous bugs in the CKEditor part and in the special character part too. I discovered these when I had finished with the Toolbook problems. I also got confused and thought that the vertical scroll bar was in the CKEditor interface but of course it's in the Toolbook field because I set allowVerticalScroll to true. I remembered doing something to show the scroll bar but I couldn't remember where or what. It came back to me in the middle of the night as is often the case. :D

I think I have now met most of the challenges but I still have a long way to go to assemble all the various parts of the program. Using CKEditor means that users should have the same tools as in the original TB and VB versions which save text as RTF files.
John Robin Dove
 
Posts: 486
Joined: Thu Jan 23, 2014 4:35 am

Next

Return to Function Help

Who is online

Users browsing this forum: No registered users and 1 guest