Here's a possible solution, but you may not like it...
Restricting the viewer from changing pages through keypresses, clicks etc will be difficult/impossible. Generally, it is not a good idea for a document to try to interfere with normal use of the viewer application, and viewer applications are unlikely to support it too, as it presents usability issues.
Therefore, my suggestion is to have all the frames in separate files and to use hyperlinks between the separate files. This will make it less likely that a player "accidentally" navigates in a way you were not anticipating.
In order to combine the OCG behaviour with the named destination/file links in this approach, I have resorted to using Javascript (my attempts with combining \hyperlink
and \actionsocg
failed). One implication that is you will need to use a supporting viewer.
So, here's jeopardy.tex
, where I have taken a looping approach to generate the table instead of repeating the code:
\documentclass{beamer}
\usepackage{ocgx}
\hypersetup{hidelinks,bookmarksdepth=1}
\usepackage{insdljs}
\setbeamertemplate{navigation symbols}{}%Removes default navigation symbols
\begin{insDLJS}[jumpTo]{jeopardy}{Jeopardy}
function jumpTo(strDest)
{
var arrayOCGs = this.getOCGs();
for(var i=0; arrayOCGs && i<arrayOCGs.length;i++)
{
if(arrayOCGs[i].name == strDest)
{
// if the corresponding OCG is invisible, ignore the click
if (arrayOCGs[i].state)
{
//app.alert("Hello World! This is \jobname. You clicked " + strDest, 3);
// make it invisible
arrayOCGs[i].state=false;
//this.gotoNamedDest(strDest);
app.openDoc("\jobname-" + strDest + ".pdf", this);
}
}
}
}
\end{insDLJS}
\newcommand*{\buttonFor}[2]{%category, number
\begin{ocg}{#1#2}{#1#2}{1}%
\PushButton[name=myButton#1#2,onclick={jumpTo("#1#2");}]{\beamerbutton{#2}}%
\end{ocg}%
}
\errorcontextlines=\maxdimen
\usepackage{etoolbox}
\newcommand{\dopoints}[1]{%#1<- points
\def\beforecellcode{}%
\forcsvlist{\docell{#1}}{Geometry,Wuzzles,Probability,MathEd,Algebra}%
\\[2ex]
}
\newcommand{\docell}[2]{%#1<- points, #2<- category
\beforecellcode
\buttonFor{#2}{#1}%
\def\beforecellcode{&}%
}%
\begin{document}
\section{Game Board}
\begin{frame}[label=gameboard]
\frametitle{\Large Mental Math Competition -- Spring 2013}
\begin{Form}% needed for \PushButton
\begin{tabular}{ccccc}
Geometry & Wuzzles & Probability & Math Ed. & Algebra\\[2ex]
\forcsvlist\dopoints{100,200,300,400,500}
\end{tabular}
\end{Form}
\end{frame}
\end{document}
Unfortunately, I could not get hyperref
's hidelinks
option to take effect for the PushButton
.
Here's jeopardy-questionbase.tex
, the template code for the game question files:
\documentclass{beamer}
\newcommand{\home}{\Acrobatmenu{Close}{\beamergotobutton{Game Board}}}
\newenvironment{questionslide}[2]% #1<- category, #2<- points
{%
\begin{frame}[environment=questionslide,fragile,label=#1#2]{#1 #2}%
}%
{%
\vfill
\home
\end{frame}%
}
For brevity, the only game question code I have presented is for Probability100
. The file should be called jeopardy-Probability100.tex
to conform with the expected naming scheme I have used in the code:
\input{jeopardy-questionbase}
\begin{document}
\begin{questionslide}{Probability}{100}
What is the sample space produced when two coins are flipped?
\end{questionslide}
\end{document}
Unfortunately, this approach does mean having a lot of .tex
files floating around, and needing to compile them all too... (If any questions are missing, it just means that the corresponding links will not work as expected, but you will still be able to test those that are available.)
Best Answer
Update:
the initial solution I proposed (it's on the bottom now) was theme-dependent since it involved a redefinition of the
footline
template (which may vary from them to theme). Here now I present a simpler solution which doesn't depend on the theme used. The idea is to use thebackground canvas
template and a\node
(inside atikzpicture
environment with theremember picture,overlay
options) to place the button at the desired location:First idea (theme dependent):
Here's one possibility; the idea is to define a command (
\AddButton
in my code) that oncludes the button as a part of thefootline
template used by theBoadilla
theme; simply issue the command at the point where the button must be included in all successive frames (you can change the position of the button by changing the lengths used in the lines marked% HERE
in my code):