Toggle button

Update: If you are a recent version of Captivate (9, 10 or 11) please have a look at :

http://blog.lilybiri.com/1-action-equals-5-toggle-buttons

Intro

In this blog posting To blog or not to blog (scroll to the end of the text please) I offered a tip to create a toggle button to turn on/off audio, playbar etc. This tip works only if a Boolean type system variable is available. Such a variable has in Captivate only two possible values: 1 (= true, yes) and 0 (= false, no).

Yesterday got this question on the user forum: How can I create a toggle button to show/hide a text caption? And I thought offering my answer in a blog post could be useful for other users. Moreover, I remember when starting this blog that it was meant to offer small tips, but now I see that a lot of my postings are not small at all :-)

Variable

To realize such a toggle, I transformed the forementioned tip a little bit. Since there is no system variable that stores the visibility of an object like a Text Caption I started by creating a user variable that would take over that role. Like the system variables (examples like cpCmndShowPlaybar,cpCmndCC, cpCmndMute) this user variable should store the value 1 when the object is visible or 0 when it is invisible. I labeled this variable  v_visib.

 

Advanced action

The advanced action to be triggered by the toggle button is a conditional action with one decision. In the Image Gallery you'll find the script for this action, labeled Toggle.

Condition is simple: check the value of v_visib

IF

v_visib is equal to 1

If this condition results in a positive answer, this means that the object (here the tekst caption labeled MyTC) is visible. It has to be made invisible (using the Hide command). Then you have to change the value of the user variable v_visib to 0. This can be done with a Assign command, but I used the same Expression as in the previous blog post about toggle, because it saves me some time: the scripts for THEN and ELSE are now identical with the exception of the first statement.  To avoid that the playhead moves on after releasing the pause of the button I rewind the playhead using the system variables rdcmndGotoFrame and rdinfoCurrentFrame.  

THEN

Hide

MyTC

 

Expression

v_vsib = 1 - v_visib

 

Assign

rdcmndGotoFrame with rdinfoCurrentFrame

If this condition results in a negative answer, this means that the object (here the tekst caption labeled MyTC) is invisible. It has to be made visible (using the Show command). Then you have to change the value of the user variable v_visib to 1. To avoid that the playhead moves on after releasing the pause of the button I rewind the playhead using the system variables rdcmndGotoFrame and rdinfoCurrentFrame

ELSE

Show

MyTC

 

Expression

v_vsib = 1 - v_visib

 

Assign

rdcmndGotoFrame with rdinfoCurrentFrame

 

More ideas

  • This toggle is not limited to show/hide captions only of course, you can use it for any object and even for more objects, edit first statement and/or add similar ones.
  • You can use a similar script for Enable/Disable too.
  • Pity that it is not possible yet to export/import small scripts like this example. However you can add the script to a template. That is a way to be able to reuse the script and not have to create it all the time.

9 responses
Thank you, thank you. This tutorial is very helpful. We just used this technique to show/hide a text version of the training that plays with a movie. The only problem we have is that the .flv movie playing in the background pauses when the toggle is activated. We're can't tell if this is standard Captivate behaviour, or an error in our implementation.
You didn't tell if it is slide video or an inserted FLV. Just tried it out with slide video: you will have to delete the last statement for both THEN and ELSE, because that is rewinding the playhead and thus stopping the video. If you delete those two statements, you will be able to toggle while the video is playing, but the playhead will move on all the time.
Hi!
Thank you for a great tutorial!
I have manged to successfully apply a toggle action to a button. So now I can show and hide an item anytime I want. But to apply this action to other items, the the item I selected in the advanced action settings, I need to create a new toggle action for every new item. Do you have a suggestion for a better way to do this?

Thank you!

Hi!
Thank you for a great tutorial!
I have manged to successfully apply a toggle action to a button. So now I can show and hide an item anytime I want. But to apply this action to other items then the the item I selected in the advanced action settings, I need to create a new toggle action for every new item. Do you have a suggestion for a better way to do this?
Thank you!
Hi Maria, indeed, that is one of the annoying things: each object in Captivate has a unique ID, which means that an advanced action that is pointing to objects has to be duplicated and edited for each slide. My suggestion is to choose the labels carefully, so that editing will be smoothly. One example for this use case: no need to create multiple user variables, you can reuse v_visib on each slide. But you'll need to label the text captions: MyTC1 (for slide 1), MyTC2 (for slide 2).... And similar for the action labels, Toggle1, Toggle2.... You can easily duplicate the advanced action, change its label from the default Duplicate of.... and edit the first statements Hide/Show to change the ID of the text caption.
Sometimes i honestly can't believe that captivate is missing out on such basics like a show/hide function (like for example Trivantis Lectora). But then i have to remind me..."it's an adobe product" and that explains almost every pain in the #
Sorry but I hear other complaints about Lectora. To have an audio clip play only on the first visit of a slide is much more complicated in Lectora than in Captivate. BTW this is a blog with free tutorials, I don't like to see ranting like that at all. Every tool has its good and bad features.
2 visitors upvoted this post.