Solving the Animated Mouse Pointer Problem for Demonstration Mode of the Simulation in ToolBook Instructor 2004
Situation
If anyone has used the Simulation Object to create a Simulation in Demonstration mode, you might have noticed a slight problem in the DHTML product. This applies to the situation where you have chosen to use the Animated Mouse feature. In this case, you should have noticed that the animated mouse pointer shows at the middle of the screen and then moves to location of your hotspot, pointing to what the learner is supposed to click, etc. on the screen.
Problem
In a lesson where you give the Learner the chance to start over and go through the simulation again during the same session, you should have noticed the problem: the mouse pointer already points to the hotspot, thus no animation. The sort of destroys the idea of having an animated mouse pointer when it does not animate!
SumTotal's Response
This is a known issue and they have provided a reasonable explanation as to why this is happening.
Solution
Thanks first to Tim Barham for a Javascript workaround (ToolBook 2004 SP1) and then to Peter Jackson (another Javascript workaround), we can easily get a desired result with very little effort. For those not using Javascript yet, this is a wonderful opportunity to learn a little.
Peter Jackson has given us this Javascript file:
|
resetcursor.js function
tbfunction_resetSimPointer(objectID, hideIt){
|
Using Javascript in ToolBook
In another demo/tutorial, I have covered the basics of using Javascript in ToolBook 2004. This will be a quick review of that. The first thing to note is that the function is prefixed with tbfunction_, thus function tbfunction_resetSimPointer. If you are familiar with functions at all, whether it be ToolBook or Javascript, information can be passed as Parameters. Here you see two: objectID and hideIt.
Importing the Javascript File
This really the easiest part. You just need to go to Object, Properties for Book, Web tab and choose Import, locating the Javascript file you wish to import.

Note that with Functions checked at the bottom, you see the name of the function minus the tbfunction_ prefix: resetSimPointer. Note also that the two parameters are listed. The one we need to work with is the objectID.
Why is the ObjectID Important?
Here's where the experts (Tim Barham and Peter Jackson) stepped up.
Quoting Tim:
"In HTML, the simulation mouse pointer is an HTML object, with a JavaScript object attached to it which provides the animation functionality. The problem here is that, in native ToolBook, the pointer always starts from the center of the screen, but in DHTML it always starts from where you last left it."
He continues to say:
"The HTML object will be a DIV
with the id "syssimPointer". However, you don't want to manipulate it
directly because the JavaScript object
keeps its own record of the current position. So you need to call a method
of the JavaScript object to set the pointer position."
I don't really understand all of this but I don't need to and I don't really care. What I care about is that he is opening a door to a solution. He goes on to give us this vital bit of information:
"The id of the simulation object will be p<page id>o<object id>,... The id of a simulation's mouse pointer is <sim id>pointer."
Now, I begin to care and pay attention because he is telling us something really important. We need to know the page id of the page the Simulation object is on, and then the id for that object. Both of these things we can easily get with Openscript. The trick is to get this information eventually passed as the value for the objectID parameter.
Tim provided some very basic Javascript to take care of the problem and then Peter provided a followup explanation with the code shown above. Peter's code is a little more robust and opened up the possibility to do a few more things with this. First, we have the objectID parameter to be used to dynamically change the reference to the object based upon what page it is on and the fact that the Simulation object will have a different id from one page to the next. Peter's code also allows for a hideIt parameter that could be used to show and hide the pointer. With a bit of additional work, we can begin to think about passing additional parameters to change the position of the pointer on each page, thus having the one function that we call each time.
Back to the objectID. In a book where there is a Simulation Object with an id of 40 on a page with an id of 1, the value for the objectID parameter to be passed to the Javascript function would need to be p1o40.
Getting the Page ID and Object ID
In my demonstration of this, I actually have created a sort of "widget" to handle most of the work. First I created two fields, naming the first one pID and the second one oID. Then I wrote this Openscript code:
"pID" Field:
notifyAfter ASYM_Reset
text of self = idNumber of parent of parent of self
end
"oID" Field:
notifyafter asym_reset
get getobjectlist(parent of parent of self, "button","")
blist=it
step p from 1 to itemcount(blist)
if ASYM_WID_QType of item p of blist=SIMULATION
get idNumber of item p of blist
simID=it
text of self=simID
end
end
end
Next, I created a button, naming it "Reset", and setting it's Caption to "ResetCursor". I then added this OS code:
notifyafter asym_reset
caption of self="Reset Cursor"
end
Next, I created the following AE code for this button after creating two global variables: pID and oID:


Note that I have both an On click and an On load page action.
For the On click event, I take the contents of the two fields (which is information that is obtained using the OpenScript shown above), append those id Numbers with "p" and "o", respectively to give the value for the variables pID and oID. These two variables are needed to build the value for the objectID parameter. When I add the Execute Script action, I obtain a list of available functions in the book based upon the js file(s) I have imported. In this case: resetSimPointer.
For the On load page event, I add code to change the caption of the button to "BeenHere". This is important since the Sim pointer object is only available after the Demonstration mode of the Simulation has run once. Thus, after the first visit to the page, the Caption is changed and then code used to check this to see if it is necessary to execute the Javascript function. Initially, I had thought about using the visited property for the page, but then issues came up with the resetting of the page (which resets the visited property).
The Execute Script Action
Here's where we do some very important work. When you double-click on the beginning of this line, you obtain the dialog box shown below. You will notice that the two parameters, objectID and hideIt show up. Now all we need to do is take the values for the pID variable and oID variable and put them together to build what becomes the objectID needed by the Javascript function (pID & oID). Simple!

Triggering the Reset Button
One final task is to set up a trigger for the Reset button. In my case, I add this code to the page and the On load page event. I could have added this to the button but in the current use of this, it was necessary to add it to the page since there is then code that resets the page (Simulation), and then starts the Simulation.

Maintenance
Finally, I group the button and the two fields together, naming the group resetCursorGroup, adding this Openscript code to hide the objects since they are not seen by the Learner.
Notifyafter asym_reset
hide self
end
notifyafter author
show self
end
notifyafter reader
hide self
end
When I am done, I copy this "widget" to all my pages and add the On load page code to trigger the Reset button. To use in another Simulation book, I could put this into a Custom Catalog.
![]()
Note that in this example here, the page ID number is 106 and the Simulation button ID number is 42. The variable pID would be equal to p106 while the variable oID would be equal to o42. Thus the value for the objectID parameter would be p106o42 for this page.