OpenerView works as expected in this:
OpenerView[{"This is the question", "This is the answer"}, False],
Yet when I put it in a loop, it has no effect:
Do[Print["hello"];
OpenerView[{"This is the question", "This is the answer"}, False], 3]
The "hello" prints fine, three times.
All I'm seeking to do is to
- print "This is the question" on the screen (1), so that
- the user needs to click to show "This is the answer" (2), and then
- they get a button saying "Next question" (3), and
- repeat (4).
The only input I need from the user is mouse clicks: to show each answer, and then once they've read it to move on to the next question.
1-2 can be got in isolation using OpenerView.
3 can be got with
ChoiceDialog["Next question", Modal -> True];
which works great in for example
Print["hello"];
ChoiceDialog["Next question", Modal -> True];
Print["world"];
But I can't get OpenerView to work in a loop so something like the following also fails to give the required output:
Do[Print["hello ", i];
ChoiceDialog["Next question", Modal -> False];
Print["world"];
OpenerView[{"This is the question", "This is the answer"}, False], 3]
I'd be grateful in advance for any help with this. I'm trying to keep it as simple as possible, but there must be something I don't understand with the functioning of OpenerView.
CellPrint
. Namely, you have to doCellPrint[OpenerView[...]]
. $\endgroup$Print[OpenerView[...]]
. $\endgroup$Table
instead ofDo
, and then use something likeColumn
to make it look nice. If you are generating a large number of OpenerViews, then I would useCellPrint
. $\endgroup$