Turning devMode ON and OFF
Now that you have created your devMode variable, you need a way to toggle it ON and OFF. My own methods for toggling devMode have evolved significantly over time.
Initially, I just set the Initial Value of the devMode variable to 1 so that it was ALWAYS ON during course development. When development was over, I changed the initial value to 0 to turn it off and republish. After a couple of close calls, I decided to make the entrance to devMode hidden so that if I forgot to turn it off, it wouldn’t be noticeable to students.
We’ll do the same: we’ll use a transparent button to turn devMode ON and OFF.
How to add a transparent button to toggle devMode
- On the Insert ribbon, click the Button drop-down list and select Transparent to add a transparent button to the page. Rename the button devEntrance.
Position the button out of the way but in a spot where you can find it without trouble.
- Select the action for devEntrance button and, in the Properties ribbon, apply the following settings:
Trigger: Mouse Click
Action: Modify Variable
Type: Set equal to
Now your invisible button can turn devMode ON!
Make the button turn devMode OFF too
Right now, the devEntrance button turns devMode on, but what if you want to be able to go back to the regular mode? You should be able to turn the variable OFF too. How do you do it?
You COULD make a second button to turn devMode off (I did at one point), but tell me… do you use ONE LIGHT SWITCH to turn your lights ON and ANOTHER to turn them OFF? No, you use a single switch that toggles between ON and OFF.
What we need is for our button to do DIFFERENT THINGS in DIFFERENT situations (turn OFF or turn ON). This is where you apply CONDITIONAL logic, which means adding an IF to your action. Here’s how the logic works…
When you click the devEntrance button, IF devMode is OFF, turn it ON.
Otherwise, IF devMode is ON, turn it OFF.
Still with me? Here’s how we program that logic into the action.
- Select the action for the devEntrance button and, on the Properties ribbon, click the Conditions button (which currently displays the word Always).
The Set Action Conditions dialog box is displayed.
- Select the following settings in the Set Action Conditions dialog box:
- Variable: devMode
- Relationship: Equal To
- Value : 0
What we are saying is that IF devMode is OFF (0), then run the action. The action, of course, will be to turn it ON (1).
Click OK to close the Set Action Conditions dialog box.
The Conditions button now displays IF (instead of Always) because you have made this action conditional.
The final step is to specify what happens when our IF condition (devMode = 0) is NOT in effect. The only way our condition can’t be met is if devMode is already ON (devMode=1). In that case, the action we want is to turn devMode OFF (change devMode = 0).
- Click the Else Action button (which currently shows No Action) and select Modify Variable from the drop-down list and enter the following settings in the Properties ribbon:
- Target: devMode
- Type: Set Equal To
- Value: 0
Now your button turns devMode on AND off. Make sense? Feel free to test it out… the only problem is that devMode doesn’t DO anything just yet, so you won’t see any difference.
This is plenty for today. In part 3 of this Downright Sneaky Lectora Tricks tutorial, we’ll add a devMode indicator to make sure it’s working.
Download the Lectora and Lectora Online files for this course in the Trivantis® Community.
John Mortenson is the Online Learning Manager for The Fresh Market. He has been developing online courses for over 10 years and is a member of the Lectora Advisory Board. He is also an Adobe Creative Suite Guru and cartoonist. You can contact him on LinkedIn and Twitter.