Recently I published some tips about learning interactions
, including an explanatory table. The use case in that post showed how to use checkbox and radiobutton interactions. Last week, a user asked a question about the dropdown interaction, which he used for a custom question slide: How can I check if the user has chosen an item? That is not difficult for checkbox and radiobutton, because their associated variable will be empty, but the situation is different for the dropdown interaction, hence this tutorial.
The most common failure that I detect on debugging advanced/shared actions with multiple decisions are due to a wrong understanding of the validation of those actions:
- all decisions will be checked from left to right
- there is no way of jumping out of the action when a correct condition is met.
In the use case from the example movie, that sequence behavior is very important!
The properties dialog box is pretty limited:
In this example you see that:
- entries are separated by commas
- formatting allows to choose a font, font style and attribute (faux style), but font size is limited to 14pt maximum
- the color dialog box doesn't show theme colors
- the update button allows to see a preview of the look after formatting
- if you want to validate the choice in the list, you need an associated variable (here v_drop); beware: you have to create the variable in the Variables dialog box
- the first sentence mentions 'combobox' but as I understand the word combobox this is not correct: in a combobox you can not only choose from a list but you can type in a word (there was an older combobox widget), this learning interaction doesn't allow that.
Maybe you are bit puzzled by the first entry 'Choose a language'? Contrary to the radiobutton/checkbox interactions, the variable associated with a dropdown is never empty! By default it has a value equal to the first item in the list. In the example movie, you will see before choosing, and after resetting that v_drop is equal to 'Choose a language'.
Resetting: it is indeed possible since this latest version of Captivate not only to change the value of a variable by an action, but also to have this change reflected in the Display of the interaction. This new feature is used for the Clear button in the example movie.
Beware: for some reason, the first time you use the interaction you will have to click twice, first click to put focus on the interaction, second click to select item. Strange :)
This movie has only 4 slides. After the 'Intro'-slide you can choose a language on slide 'Drop'. Watch the variable v_drop that is visible in a text caption next to the learning interaction. You get 3 attempts to guess the correct language, reason for the variable v_attempts. The 'Drop' slide has two interactive objects: Submit and Clear. Try out Clear to see how the interaction is reset to its initial state. You can click Submit without choosing a language, you can choose a wrong language or the correct one. The third slide you'll only see when your answer is correct. If you exhaust the three attempts without correct result, you will end up at the 4th slide 'Retry', where you are able to get back to the 'Drop' slide and start guessing again.
Here is a screenshot of the user variables
As explained before v_attempts tracks the number of attempts and starts with value=3, v_drop is the associated variable for the dropdown interaction.
I used v_dummy, a variable containing the text 'Choose a language' out of laziness, to avoid having to type that text over and over again. Be careful: it has to be exactly the text in the first item, it is not possible to use a variable in the item list.
The variable v_groet is used on the third slide, to customize the text based on the current time of the user (cpInfoCurrentHour). The variable v_wrong is a Boolean (value=0) that will be set to 1 when the attempts are exhausted without finding the correct language.
Events and Actions
EnterDrop, triggered On Enter for slide Drop
This standard action resets everything on the second slide 'Drop': the group Gr_Feedback with empty, wrong and correct feedback messages (empty, wrong, correct) is hidden, group Gr_Bt with the two interactive objects made visible, variables v_drop and v_wrong are reset to the default values.
ResetAct, triggered by the Success event of the Clear interactive object
A standard action that restores v_drop to its default value and hides the group Gr_Feedback.
CheckSubmit, triggered by the Success event of the Clear interactive object
This conditional action has 5 decisions, one for each possible situation:
- EmptyDone if the user clicked on Submit without making a choice and it was the last attempt
- Empty if the user clicked on Submit without making a choice and there are still attempts left
- WrongDone if the user choose a wrong language and it was the last attempt
- Wrong if the user choose a wrong language and there are still attempts left
The Sequence is important: if you put Empty before EmptyDone, it goes awry if it is the second attempt, because Empty would have decremented v_attempts and that means that EmptyDone would result also in a True condition, and user will lose an attempt. Same for WrongDone and Wrong, they cannot be switched.
ExitDrop, triggered by On Exit event of slide Drop
Exceptionally I use the On Exit event, because in this case it will function perfectly.
A simple conditional action, based on the value of v_wrong.
There is a simple Jump to slide 'Drop' on the last slide. Resetting will happen with EnterDrop action.
The third slide has an On Enter action, to show the right caption based on the system variable cpInfoCurrentHour.
Do you accept the challenge to figure out that (conditional) action? No need to use my tongue :)